Skip to content

Instantly share code, notes, and snippets.

@epitron
Created August 15, 2014 22:01
Show Gist options
  • Save epitron/a4fcebd17e871fa39d99 to your computer and use it in GitHub Desktop.
Save epitron/a4fcebd17e871fa39d99 to your computer and use it in GitHub Desktop.
Crazy 3-line tower of Hanoi solver.
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
@SVMBrown
Copy link

Whoa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment