Created
August 15, 2014 22:01
-
-
Save epitron/a4fcebd17e871fa39d99 to your computer and use it in GitHub Desktop.
Crazy 3-line tower of Hanoi solver.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "How many disks? " | |
n = STDIN.gets.to_i | |
x = 1 | |
while (x < (1 << n)) | |
puts "move from pole #{(x&x-1)%3} to pole #{((x|x-1)+1)%3}" | |
x += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whoa.