Tower of Hanoi is a game consisting of three pegs and eight plates of increasing diameter, with the end goal of transferring the plates from peg 1 to peg 3 without laying a large plate on a smaller plate.

This game can be solved with a recursive algorithm: Precondition: all three poles have their plates in valid order

# work on top n plates
# move src plates to dst
# use tmp as temporary pole
def hanoi(n, src, tmp, dst):
    if n == 1: # base case
        # move a single plate
        move(src, dst)
    else:
        # move the plates above the heaviest to tmp pole
        hanoi(n-1, src, dst, tmp)
        # move the currently heavest plate from src to dst
        move(src, dst)
        # move the rest of the plates from tmp to dst
        hanoi(n-1, tmp, src, dst)