curious in case anyone might know how to structure a program to solve sudoku puzzles? input would be a list of the 81 numbers from left to right, top to bottom with zeroes where empty characters would be, output would be the filled out grid.
How can I program a sudoku program?
- Posted:
- 3+ months ago by ForAllExi...
- Topics:
- number, program, puzzle
Responses (1)
A program can be written with the same deterministic logical capabilities of a human, with the advantage of heightened processing speed, virtually unlimited memorisation and depth of methods.
There are plenty of ways of varying complexity. A simple one is marking all the options per cell (negating filled numbers in row, column or grid), filling out a cell which has only one option or a row / col / grid which has only one position for a certain number, and repeat. If there are no more such certainties, there are advanced techniques which could be sought, but a (simple) program can also afford recursion - save current state, pick a cell with 2 options, try one and see whether it reaches a solution or dead end and revert in the latter case.
This whole process if written correctly would probably take less than a minute, the cs people prefer to even the odds by asking how can the algorithm's time complexity be improved, solving for arbitrarily large grid, limiting space usage etc.