Created
February 26, 2018 01:04
-
-
Save jmuzsik/4d270a3450e4c21a044ad7e0db2b13e6 to your computer and use it in GitHub Desktop.
This file contains 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
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