Created
May 3, 2018 22:11
-
-
Save jimbog/f1ce850be9da14ac7e48bd42d1a4adc5 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
total = 0 | |
def hanoi(n, _from, _to, _support): | |
global total | |
if n == 1: | |
total += 1 | |
print 'move', n, 'from: ', _from, 'to', _to | |
else: | |
hanoi(n - 1, _from, _support, _to) | |
total += 1 | |
print 'move', n, 'from: ', _from, 'to', _to | |
hanoi(n - 1, _support, _to, _from) | |
hanoi(6, 'a', 'b', 'c') | |
print total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment