Advertisement
_Mizanur

TowerofHanoi

Oct 25th, 2021
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1.  
  2. def TOH(n,A,B,C):
  3.     if n>0:
  4.         TOH(n-1,A,C,B)
  5.         print('Moved disk',n,'from',A,'to',C)
  6.         TOH(n-1,B,A,C)
  7.         i = i + 1
  8. n=int(input("Enter How many disk:"))
  9. TOH(n,'A','B','C')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement