Brute force sudoku cracker
Sybren Stuvel
sybrenUSE at YOURthirdtower.com.imagination
Sat Sep 17 05:39:02 EDT 2005
Bas enlightened us with:
> I came across some of these online sudoku games and thought after
> playing a game or two that I'd better waste my time writing a solver
> than play the game itself any longer. I managed to write a pretty
> dumb brute force solver that can at least solve the easy cases
> pretty fast.
I've got a solver too - I'm joining the Linux Format programming
contest. My program can solve and create Sudoku puzzles - and not only
9x9 ones. Check http://www.unrealtower.org/sodoku. In the LFX
programming contest they call the puzzle Sodoku, not Sudoku, so that's
why I'm sticking with the name Sodoku for now.
> -any improvements possible for the current code? I didn't play a lot
> with python yet, so I probably missed some typical python tricks,
> like converting for-loops to list expressions.
It all depends on what you want to do. My program can create & solve
puzzles from any size, load and save them to disk, check them for
validity and rank them ('easy', 'medium', 'hard', 'near impossible').
It also implements a puzzle in a class, so it can be used in an OOP
fashion.
> def all(seq, pred=bool):
What's this? What is bool?
Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
More information about the Python-list
mailing list