Note: On mobile devices, instead of dragging and dropping, you just tap the rings and then the peg where you want to put it.
#solve in Python
def tower_of_hanoi(n, source="A", auxiliary="B", destination="C"):
if n == 1:
print(f"Move disk 1 from {source} to {destination}")
return
#move n-1 disks from source to auxiliary peg
tower_of_hanoi(n-1, source, destination, auxiliary)
#move the 'n' disk from source to destination
print(f"Move disk {n} from {source} to {destination}")
#the n-1 disks from auxiliary to destination peg
tower_of_hanoi(n-1, auxiliary, source, destination)
#example usage #this is also what is considered a coding principle way
if __name__ == "__main__":
num_disks = int(input("Enter the number of disks: "))
tower_of_hanoi(num_disks)