Skip to content

Commit

Permalink
improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
harshildarji committed Aug 14, 2016
1 parent 8d5be8a commit 45af05b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
33 changes: 0 additions & 33 deletions Tower_of_Hanoi.py

This file was deleted.

25 changes: 25 additions & 0 deletions other/tower_of_hanoi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def moveTower(height, fromPole, toPole, withPole):
'''
>>> moveTower(3, 'A', 'B', 'C')
moving disk from A to B
moving disk from A to C
moving disk from B to C
moving disk from A to B
moving disk from C to A
moving disk from C to B
moving disk from A to B
'''
if height >= 1:
moveTower(height-1, fromPole, withPole, toPole)
moveDisk(fromPole, toPole)
moveTower(height-1, withPole, toPole, fromPole)

def moveDisk(fp,tp):
print('moving disk from', fp, 'to', tp)

def main():
height = int(input('Height of hanoi: '))
moveTower(height, 'A', 'B', 'C')

if __name__ == '__main__':
main()

0 comments on commit 45af05b

Please sign in to comment.