Learn Recursion by Solving the Tower of Hanoi Puzzle - Step 31

The code seems fine, but the tester is not accepting. I even ran the following steps and they seemed to be working fine as well, though the testing of the subsequent steps may not depend on the code in step 31https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-recursion-by-solving-the-tower-of-hanoi-puzzle/step-31

Could you share your code?

Yeah sure. Is the link creating an issue? If you click it, it should take you to the code

Yeah, but not to the changes that you made.

The issue is with this piece:

def make_allowed_move(rod1, rod2):
    forward = False
    if not rods[target]:
        forward = True
    elif rods[source] and rods[source][-1] < rods[target][-1]:
        forward = True
    if forward:
        print(f'Moving disk {rods[source][-1]} from {source} to {target}')
        rods[target].append(rods[source].pop())
    else:
        print(f'Moving disk {rods[target][-1]} from {target} to {source}')
        rods[source].append(rods[target].pop())
    #display our progress
    print(rods)

def move(n, source, auxiliary, target):
    # display starting configuration
    print(rods)
    for i in range(number_of_moves):
        remainder = (i + 1) % 3
        if remainder == 1:
            print(f'Move {i + 1} allowed between {source} and {target}')

Thanks, test is a bit strict in this step, if you add space after the # on the below line, it will pass.

    # display our progress

Thanks a lot man. Done it! The tester’s gonna give people sleepless nights one of these days. New year’s greetings

1 Like

hey Sanity, i got the same problem but already had space in between the comment and the hashtag. nevertheless its not passing :frowning: have i misunderstood smtn here?

def make_allowed_move(rod1, rod2):
    forward = False
            if not rods[target]:
                forward = True
            elif rods[source] and rods[source][-1] < rods[target][-1]:
                forward = True
            if forward:
                print(f'Moving disk {rods[source][-1]} from {source} to {target}')
                rods[target].append(rods[source].pop())
            else:
                print(f'Moving disk {rods[target][-1]} from {target} to {source}')
                rods[source].append(rods[target].pop())

            # display our progress
            print(rods) 

def move(n, source, auxiliary, target):
    # display starting configuration
    print(rods)
    for i in range(number_of_moves):
        remainder = (i + 1) % 3
        if remainder == 1:
            print(f'Move {i + 1} allowed between {source} and {target}')

Hey @d.v.behrendt, for convenience please start new thread.