Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a sudoku puzzle
| ResourceFunction["GenerateSudokuPuzzle"][] generates a 9×9 sudoku puzzle with half of the elements exposed. | |
| ResourceFunction["GenerateSudokuPuzzle"][d] generates a d2×d2 sudoku puzzle with half of the elements exposed. | |
| ResourceFunction["GenerateSudokuPuzzle"][d,p] generates a d2×d2 sudoku puzzle with p percent of the elements exposed. | 
Generate a standard sudoku puzzle:
| In[1]:= | ![{refSudokuPuzzle, sudokuPuzzle} = ResourceFunction["GenerateSudokuPuzzle"][]](https://www.wolframcloud.com/obj/resourcesystem/images/c65/c65631c2-cc56-4250-9b52-7321392c9617/513f57f0eef611b1.png) | 
| Out[1]= |  | 
Display the results using the resource function DisplaySudokuPuzzle:
| In[2]:= | ![ResourceFunction["DisplaySudokuPuzzle"][#] & /@ {refSudokuPuzzle, sudokuPuzzle}](https://www.wolframcloud.com/obj/resourcesystem/images/c65/c65631c2-cc56-4250-9b52-7321392c9617/0811f51e7d1832fa.png) | 
| Out[2]= |  | 
Solve the resulting sudoku puzzle using the resource function SolveSudokuPuzzle to confirm that the reference puzzle is obtained:
| In[3]:= | ![ResourceFunction["DisplaySudokuPuzzle"][
 ResourceFunction["SolveSudokuPuzzle"][sudokuPuzzle]]](https://www.wolframcloud.com/obj/resourcesystem/images/c65/c65631c2-cc56-4250-9b52-7321392c9617/2967508b986b5dff.png) | 
| Out[3]= |  | 
Generate a 16⨯16 sudoku puzzle with 70% of the elements exposed:
| In[4]:= | ![{refSudokuPuzzle, sudokuPuzzle} = ResourceFunction["GenerateSudokuPuzzle"][4, 0.7]](https://www.wolframcloud.com/obj/resourcesystem/images/c65/c65631c2-cc56-4250-9b52-7321392c9617/1db9f52e2c6c946d.png) | 
| Out[4]= |  | 
Display the results using the resource function DisplaySudokuPuzzle:
| In[5]:= | ![ResourceFunction["DisplaySudokuPuzzle"][#] & /@ {refSudokuPuzzle, sudokuPuzzle}](https://www.wolframcloud.com/obj/resourcesystem/images/c65/c65631c2-cc56-4250-9b52-7321392c9617/0aab7aaa7dbcb1ea.png) | 
| Out[5]= |  | 
If the specified exposed percentage is too low then the function will return a puzzle with the smallest number of elements exposed such that the resulting sudoku puzzle is unique:
| In[6]:= | ![{refSudokuPuzzle, sudokuPuzzle} = ResourceFunction["GenerateSudokuPuzzle"][3, 0]](https://www.wolframcloud.com/obj/resourcesystem/images/c65/c65631c2-cc56-4250-9b52-7321392c9617/2a1d75d284118f53.png) | 
| Out[6]= |  | 
| In[7]:= | ![ResourceFunction["DisplaySudokuPuzzle"][#] & /@ {refSudokuPuzzle, sudokuPuzzle}](https://www.wolframcloud.com/obj/resourcesystem/images/c65/c65631c2-cc56-4250-9b52-7321392c9617/41ff85dda7e8f8a9.png) | 
| Out[7]= |  | 
Solve the resulting sudoku puzzle using the resource function SolveSudokuPuzzle to confirm that the reference puzzle is obtained:
| In[8]:= | ![ResourceFunction["DisplaySudokuPuzzle"][
 ResourceFunction["SolveSudokuPuzzle"][sudokuPuzzle]]](https://www.wolframcloud.com/obj/resourcesystem/images/c65/c65631c2-cc56-4250-9b52-7321392c9617/371aeba6490cfaa7.png) | 
| Out[8]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License