Skip to content

Instantly share code, notes, and snippets.

@dalejung
Created June 9, 2015 00:39
Show Gist options
  • Save dalejung/51ff0f9817a224e08e6e to your computer and use it in GitHub Desktop.
Save dalejung/51ff0f9817a224e08e6e to your computer and use it in GitHub Desktop.
hanoi.py
def towers(num, frompeg, topeg, aux, final):
if num > 0:
towers(num-1, frompeg, aux, topeg, False)
if final:
print('final')
print("move disk %d from %s to %s" % (num, frompeg, topeg))
towers(num-1, aux, topeg, frompeg, final)
towers(5, 'A', 'B', 'C', True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment