Tower of Hanoi
Description: A small function that helps solving the Tower of Hanoi Game by telling which moves to do
Photos / Video:
Download link:
def hanoi(n,A,B,C):
if n>0:
hanoi(n-1,A,C,B)
print(A,"-->",B)
hanoi(n-1,C,B,A)
n=int(input("Number of Disk: "))
hanoi(n,"A","B","C")
#-------------------------------------------
# n = Number of Disks
# Where A represents Tower 1(Left one)
# Where B represents Tower 2(Middle one)
# Where C represents Tower 3(Right one)
Source (optional): -
Other mentions: Click here to play the Tower of Hanoi