Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input('Enter the number of disk: '))
- total_move = pow(2,n)-1;
- print("Total Moves = "+str(total_move)+"\nHere the steps for moving disks from A to C:");
- def moveTower(n,source, aux, destination):
- if n >= 1:
- moveTower(n-1,source,destination,aux)
- print("moving disk from",source,"to",destination)
- moveTower(n-1,aux,source,destination)
- moveTower(n,"A","B","C")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement