💡 I will spend all day preparing for tomorrow’s interviews.

🖥️ Implement the Tower of Hanoi Algorithm Certification Project

def hanoi_solver(n):
    left = list(range(n, 0, -1))
    middle = []
    right = []

    moves = []

    def record():
        moves.append(f'{left} {middle} {right}')

    def move(disk_count, source, target, auxiliary):
        if disk_count == 0:
            return
        move(disk_count - 1, source, auxiliary, target)
        target.append(source.pop())
        record()
        move(disk_count - 1, auxiliary, target, source)
    record()
    move(n, left, right, middle)
    return "\n".join(moves)

465 of 521 steps complete

🖱️ Did some work

🏄‍♀️ Started surfing


<
Previous Post
0324 YOUR DEEDS ARE YOUR MONUMENTS
>
Blog Archive
Archive of all previous blog posts