Skip to content

Instantly share code, notes, and snippets.

@SmashedFrenzy16
Last active March 4, 2023 10:36
Show Gist options
  • Save SmashedFrenzy16/cb317b360c923148e6fde4085f5cbb27 to your computer and use it in GitHub Desktop.
Save SmashedFrenzy16/cb317b360c923148e6fde4085f5cbb27 to your computer and use it in GitHub Desktop.
A command-line Hanoi Tower made in Python!
def towerOfHanoi(n, fromRod, toRod, auxRod):
if n ==0:
return
towerOfHanoi(n-1, fromRod, auxRod, toRod)
print("Move disk",n,"From rod",fromRod,"to rod",toRod)
towerOfHanoi(n-1, auxRod, fromRod, toRod)
n = 6
towerOfHanoi(n, "A", "C", "B")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment