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!
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.
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.