Solving the Knight's Tour Puzzle In 60 Lines of Python 311
ttsiod writes "When I was a kid, I used to play the Knight's Tour puzzle with pen and paper: you simply had to pass once from every square of a chess board, moving like a Knight. Nowadays, I no longer play chess; but somehow I remembered this nice little puzzle and coded a 60-line Python solver that can tackle even 100x100 boards in less than a second. Try beating this, fellow coders!"
awesome (Score:5, Funny)
too bad that your code will break with the next python version.
Easy (Score:5, Funny)
C-x C-m KnightsPuzzle
What would Michael Knight do? (Score:4, Funny)
He'd hop into KITT and go anywhere he damn well pleases.
Re:OK (Score:4, Funny)
Re:All done. (Score:5, Funny)
Except you commented out all of the code.
Python has "perfect syntax"? (Score:1, Funny)
Please... Why do we need slashvertisements for programming languages on Slashdot?
Re:All done. (Score:5, Funny)
There. I did it in one line of code.
That doesn't look like perl to me...
OMG (Score:4, Funny)
Re:A trivial backtracking algorithm and... (Score:5, Funny)
Of course like all other programmers he thinks he is better then everyone else.
Re:All done. (Score:5, Funny)
Re:awesome (Score:5, Funny)
Re:All done. (Score:5, Funny)
Re:All done. (Score:3, Funny)
Knuth (Score:3, Funny)
He's preached against premature optimization for years.
Re:better algo (Score:5, Funny)
Wait a second. What's wrong with recursion?
Re:printf (Score:4, Funny)
No output, and your font is all wrong.
*ducks*
Re:printf (Score:3, Funny)
It will run 1/10th the speed of Python?
1 line from the future (.NET 4.0) (Score:3, Funny)
object[] finalBoard = System.Math.KnightsTour(64);
Re:printf (Score:4, Funny)
You misspelled puts? ;-D
Half in size-Double in speed...with Perl (Score:2, Funny)
Re:Knuth (Score:3, Funny)
Re:better algo (Score:3, Funny)
I don't know. What's wrong with recursion?