Solving the Knight's Tour Puzzle In 60 Lines of Python
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!"
too bad that your code will break with the next python version.
C-x C-m KnightsPuzzle
He'd hop into KITT and go anywhere he damn well pleases.
I blow my nose at you, so-called "Arthur King", you and all your silly English K-nigg-its.
No folly is more costly than the folly of intolerant idealism. - Winston Churchill
Except you commented out all of the code.
Please... Why do we need slashvertisements for programming languages on Slashdot?
There. I did it in one line of code.
That doesn't look like perl to me...
Now let's see, they taught us about this problem back when I was a six- or seven-grader (~'90-91, can't recall exactly) as one of the illustrations for backtracking (yes, I know we can do it without backtracking, that was not the point then I guess). Go figure.
I am putting myself to the fullest possible use, which is all I can think that any conscious entity can ever hope to do.
Of course like all other programmers he thinks he is better then everyone else.
If something is so important that you feel the need to post it on the internet... It probably isn't that important.
Woosh.
From experience, commenting out the code makes it better. :P
If you can read this, I forgot to post anonymously.
In my experience, every line commented out makes the program run faster. My programs tend to run instantly if I comment the entire thing! Using a # must invoke an incredible optimization engine! Why don't they use it by default?
He's preached against premature optimization for years.
Wait a second. What's wrong with recursion?
I'm a big retard who forgot to log out of Slashdot on Mike's computer! LOOK AT ME.
No output, and your font is all wrong.
*ducks*
It will run 1/10th the speed of Python?
object[] finalBoard = System.Math.KnightsTour(64);
You misspelled puts? ;-D
Can't copy n' paste the code here because I get the message: "Try not to use so many 'junky' words"! So, this is how Slashdot behaves to the language that brought it to life. Anyway,you can find the Perl script here.
I don't know. What's wrong with recursion?
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.