Skip to content

Instantly share code, notes, and snippets.

@ecylmz
Created November 10, 2010 14:06
Show Gist options
  • Save ecylmz/670885 to your computer and use it in GitHub Desktop.
Save ecylmz/670885 to your computer and use it in GitHub Desktop.
def hanoi(n, a='A', b='B', c='C'):
"""
move n discs from a to c using b as middle
"""
if n == 0:
return
hanoi(n-1, a, c, b)
print a, '->', c
hanoi(n-1, b, a, c)
hanoi(32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment