Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Solve Sudoku puzzles
| ResourceFunction["SudokuSolve"][data] treats a 9×9 matrix of data as a partially solved Sudoku puzzle and replaces all elements that are not integers from 1 to 9 with the correct elements to fully solve the puzzle. | 
Solve a puzzle:
| In[1]:= | ![ResourceFunction["SudokuSolve"][ {
  { ,  , 8, 1, 7, 6,  , 2,  },
  { , 4,  ,  ,  , 9, 7,  ,  },
  { ,  ,  ,  ,  ,  ,  ,  ,  },
  { , 7, 1, 8,  ,  ,  ,  ,  },
  { ,  ,  ,  ,  ,  , 6, 7, 9},
  { ,  ,  , 5, 9, 7,  , 8, 1},
  { ,  ,  ,  , 2,  ,  ,  ,  },
  { , 5, 9,  ,  ,  ,  , 1,  },
  { , 1, 4, 6, 5,  , 3,  ,  }
 } ]](https://www.wolframcloud.com/obj/resourcesystem/images/c33/c335a0ac-c033-4087-9930-28e30e030631/1744d064554952cc.png) | 
| Out[1]= |  | 
The option "ShowSteps" shows when it was necessary to guess values rather than use pure logic:
| In[3]:= | ![ResourceFunction["SudokuSolve"][{
  {5, 3, 8, 1, 7, 6,  , 2,  },
  { ,  ,  ,  ,  , 9, 7,  ,  },
  { ,  ,  ,  ,  ,  ,  ,  ,  },
  { , 7, 1, 8,  ,  ,  ,  ,  },
  { ,  ,  ,  ,  ,  , 6, 7, 9},
  { ,  ,  , 5, 9, 7,  , 8, 1},
  { ,  ,  ,  , 2,  ,  ,  ,  },
  { , 5, 9,  ,  ,  ,  , 1,  },
  { , 1, 4, 6, 5,  , 3,  ,  }
 } , "ShowSteps" -> True]](https://www.wolframcloud.com/obj/resourcesystem/images/c33/c335a0ac-c033-4087-9930-28e30e030631/1028f8594abe9eb6.png) | 



| Out[3]= |  | 
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License