Added Dequeue in Python

This commit is contained in:
97arushisharma
2017-10-25 01:37:11 +05:30
commit 9bc80eac2d
105 changed files with 295341 additions and 0 deletions

25
other/tower_of_hanoi.py Normal file
View File

@ -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()