Function Repository Resource:

SudokuSuguruAssistant

Source Notebook

Open an interface for entering and interactively solving given or generated sudoku and suguru puzzles

Contributed by: Fred Simons

ResourceFunction["SudokuSuguruAssistant"][]

opens an interface for interactively entering and solving a standard sudoku puzzle.

ResourceFunction["SudokuSuguruAssistant"][{r,c}]

opens an interface for a suguru puzzle with r rows and c columns.

ResourceFunction["SudokuSuguruAssistant"][type]

opens an interface for a single sudoku puzzle of the specified type.

ResourceFunction["SudokuSuguruAssistant"][{loc1,type1},{loc2,type2},]

opens an interface for a multi-sudoku puzzle.

ResourceFunction["SudokuSuguruAssistant"][str]

opens an interface for a puzzle specified by data in the string str.

Details

The user is able request hints at any stage of the solving process.
The typei specifies the (sub)sudoku type: "standard", "diagonal", or "jigsaw".
The loci for multi-sudoku puzzles are strings and specify the row and column of the top-left corner. For example, "R4C7" if the corner lies in row 4, column 7. When the type is "standard", the loci can be used instead of the list {loci, typei}.
The result is an interface whose main component is an empty sudoku or suguru. For a jigsaw (sub)sudoku or a suguru the block or region lines still have to be drawn. That is done by clicking the corresponding cell borders. To remove a line element click it once again.
Move the cursor to the cell and type digits to enter clues. Click on a clue to remove it.
For standard sudokus and sugurus with a size at most 9x9 one may press the "Generate" button to get a random puzzle.
At any stage when interactively entering or solving the puzzle, choosing the item "String" in the action menu will give a string in compressed format containing information about the sort of puzzle and the line elements and clues entered thus far. This string is placed on the clipboard as well and can be used as an argument for a later call to this function. This effectively allows one to restart the game at a later time or in a new session.
After entering the puzzle correctly, press the "Manual Solve" button. You can then solve the puzzle just as you would with pencil and paper. For placing a number in an empty cell, put the cursor in that cell and type the number. To remove a placed number, click that number.
In "Manual Solve" mode, open cells can be used for making notes about the candidates that can be placed in those cells. To enter a candidate, move the cursor to the cell and type the candidate while holding down the left mouse button. To remove an entered candidate, enter that candidate once more. Candidates are shown in a much smaller font than guesses. Entering candidates has no restrictions; any candidate can be entered in any cell, even if it cannot occur there. The candidates in a cell can be underlined by moving the cursor to the cell and right-clicking (repeat this action to remove the underlining). Underlining is telling the program that the cell cannot have other candidates than those in the cell.
Whenever a number is placed or candidates are underlined in a cell, the input is compared to the solution of the puzzle. If it conflicts, an error message is shown.
At any time during solving, a hint can be requested by pressing the "Hint" button. The hint appears at the bottom of the screen and consists of a sequence of reductions that can be applied step by step, ending in a single placement. Clicking any reduction highlights the relevant cells with color coding. Each reduction shows the name of the logical rule it uses. More information about these rules can be found by choosing "Documentation" in the action menu above the puzzle.
When the "Apply" button of a hint is pressed, only the computed single is placed.
By using the action menu, or by pressing the corresponding button in "Enter" mode, we can switch to "Assisted Mode". In this mode, all candidates are displayed. Numbers and candidates can be placed or removed, always consistent with the solution. When a hint is requested and applied in "Assisted Mode", the next hint is generated automatically.
After the puzzle is entered correctly, pressing "Manual" or "Assisted Solve" displays an association with properties of the puzzle. The first key is "Sudoku" or "Suguru", whose value is the positions and types of the subsudokus, or the size for a suguru. The second key "Clues" gives the number of clues. The next keys are logical rules, with value how often that rule was used in solving. The final key "String" gives the string representation of the puzzle, without placed numbers or candidates.
The properties can be requested via the action menu under "Properties" and are then shown in the interface and placed on the clipboard.

Examples

Basic Examples

This opens an interface for entering and solving a 6x6 suguru:

In[1]:=
ResourceFunction["SudokuSuguruAssistant"][{6, 6}]

Click the cell borders to draw the regions, enter the clues, and press Manual Solve to obtain:

The following shows the result after placing a 1 in cell R3C2; recording that candidate 4 can appear in cells R5C3 and R6C2; that only candidates 1 and 2 can occur in cells R4C6 and R5C6; and that only candidates 2 and 4 can occur in cells R2C3 and R2C4:

Pressing the Hint button shows how we could proceed:

In the output above the first item in the hint has been clicked, so that the color info of that item is displayed.

At any time, we can use the action menu to inspect the solution:


Open an interface for entering and solving a standard sudoku:

In[2]:=
ResourceFunction["SudokuSuguruAssistant"][]

Press Generate to enter a random puzzle (this may take some time):

Start solving interactively. After some time, request a hint. The XY-chain is highlighted:


Open the interface for solving a 6x6 suguru:

In[3]:=
ResourceFunction["SudokuSuguruAssistant"][{6, 6}]

Enter some line elements and clues, for example as in the next output and press String in the action menu:

The string is in on the clipboard, so you can paste it in the next command:

In[4]:=
ResourceFunction[
 "SudokuSuguruAssistant"]["376Cud%Rqrc4r7yI6LC|1L8|1RoXn87!BxQbToAdum"]

The result is an interface identical to the one we started with.


This opens the interface for entering and solving a multi-sudoku consisting of a jigsaw sudoku and a diagonal sudoku:

In[5]:=
ResourceFunction[
 "SudokuSuguruAssistant"][{"R1C1", "jigsaw"}, {"R7C7", "diagonal"}]

This is the result after having entered the puzzle and pressing String in the action menu:

Call the function with the string. You can then immediately press Manual Solve and start solving:

In[6]:=
ResourceFunction[
 "SudokuSuguruAssistant"]["3sAfeaTYJYrg94ngDy8Ddo5A%q&h70TYhdh7c%F&L1nebZvDoDU3Ss77xlXJm$$ZizV3qPEI584hex78v1W|4nxNL|HkT4pZLpbSdRGCQBLTl0usa0ZQ$%WfSnmZrbde"]

Publisher

Fred Simons

Requirements

Wolfram Language 14.0 (January 2024) or above

Version History

  • 1.0.0 – 17 September 2025

Related Resources

License Information