Skip to content

Instantly share code, notes, and snippets.

@jmuzsik
Created February 26, 2018 01:04
Show Gist options
  • Save jmuzsik/4d270a3450e4c21a044ad7e0db2b13e6 to your computer and use it in GitHub Desktop.
Save jmuzsik/4d270a3450e4c21a044ad7e0db2b13e6 to your computer and use it in GitHub Desktop.
def moveTower(n, source, dest, temp):
if n == 1:
print("Move disk from", source, "to", dest+".")
else:
moveTower(n-1, source, temp, dest)
moveTower(1, source, dest, temp)
moveTower(n-1, temp, dest, source)
def hanoi(n):
moveTower(n, "A", "C", "B")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment