Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Sudoku in 201 lines (caboo.se)
1 point by dhotson on March 30, 2008 | hide | past | favorite | 6 comments


I should have read the comment before the code. I was just coming to the conclusion that the code could not solve the harder sudokus.

The wikipedia article on "Algorithmics of Sudoku" is a start for tips. There is a Scientific American article that has a good overview of the problem... http://www.cs.utexas.edu/~kuipers/readings/Sudoku-sciam-06.p...

Don't google for Lispers writing solvers. They will make you feel all bloated.


I got bored at work and had a go at a sudoku solver in Ruby. It can solve most medium difficulty puzzles. Any tips on improving my code would be appreciated!


Peter Norvig's solution is more elegant (he just brute forces it), it works on all puzzles and is just 100 lines of Python

http://norvig.com/sudoku.html


glad someone mentioned it. there is no point in NOT brute forcing a problem such as this when it doesn't really take all that much brute force to begin with. What good is a sudoku solving algorithm? Algorithm's are to eliminate the need for brute force when brute force would take too long/require too much resources.


Hmm.. good point. I didn't really consider brute force to be viable. Is it actually necessary on some of the harder puzzles? Or can they be deduced solely using logic and without 'guessing'?


I'm not positive because I don't really play the puzzles a lot. But i think some of them require mentally filling in a space and seeing if it leads to a contradiction.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: