Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a giant hashtable to solve a sudoku in polynomial time

Say you were to create a hash table that maps every possible valid 9x9 sudoku (not yet filled in) to its solution. (as infeasible a task as this would be)

Then you were to create a simple program that takes a valid 9x9 sudoku (again, not yet filled in) as input and returns the solution that is mapped to it in the hashtable described above.

Would this not be considered a sudoku solver that works in polynomial time?

Is there something about this theoretical solution that disqualifies it from being proof that sudoku is a P class problem?

like image 628
svaerth Avatar asked Jan 02 '23 14:01

svaerth


1 Answers

I think you're misunderstanding the problem. From Wikipedia:

The general problem of solving Sudoku puzzles on n^2×n^2 grids of n×n blocks is known to be NP-complete.

Although the game may most usually come in a 9x9 variant, the generally-stated problem characterizes the relationship between the size of the grid and the complexity of finding a solution - not any individual grid. If your hypothetical is true, it would not fundamentally change the classification of the problem.

Also, consider how you would retrieve a candidate solution from such a hash table. If you use as the keys the sequence of all initial values and their locations, then you would need to keep all possible sets of initial values (81 choose 30, 1.4e22) - for each unique solution (6.7e21). (And that's only for solutions that start with thirty values showing...)

like image 187
Max Vu Avatar answered May 16 '23 09:05

Max Vu