<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">def solve_hanoi(n, start, goal, temp):
    """Prints out the instructions for moving n disks (ordered
    smallest to largest, going down) from the start to the 
    goal, using the temp, as needed.

    Preconditions: 
    start, goal, and temp are strings
    n is an integer"""
    
    if n == 1:
        # it's easy to move just 1 disk!
        print("move from " + start + " to " + goal)
        
    else:
    
        # it's harder to move multiple disks. We have to first move
        # the top n-1 disks temporarily to "temp" then move the
        # largest disk to the target peg. Then move the remaining n-1
        # disks back on top of thh largest @ target.

        # temporarily move all but the last disk to the "other peg"
        # how can we do this? Check the specs of THIS FUNCTION. It
        # can do exactly this!
        solve_hanoi(n-1, start, temp, goal)
        
        # move the last disk to the target peg 
        print("move from " + start + " to " + goal)

        # now move all but the last disk to the target peg
        # again, how can we do this? we can call THIS FUNCTION
        solve_hanoi(n-1, temp, goal, start)


n_disks = int(input("How many disks are on your tower? "))
print("That's easy! Here's what you do: ")

solve_hanoi(n_disks, "left", "right", "middle")
</pre></body></html>