curriculum/challenges/english/blocks/learn-recursion-by-solving-the-tower-of-hanoi-puzzle/64df3e2fac34d813d048f3f9.md
You won't need make_allowed_move and number_of_moves, either. Delete the whole function and the variable.
You should delete the number_of_moves variable and its content.
({ test: () => assert.match(code, /NUMBER_OF_DISKS\s*=\s*4\s+(?=rods\s*=\s*\{)/) })
You should delete the whole make_allowed_move function.
({ test: () => assert.match(code, /\}\s+(?=def\s+move\(\s*n\s*,\s*source\s*,\s*auxiliary\s*,\s*target\s*\)\s*:)/) })
--fcc-editable-region--
NUMBER_OF_DISKS = 4
number_of_moves = 2 ** NUMBER_OF_DISKS - 1
rods = {
'A': list(range(NUMBER_OF_DISKS, 0, -1)),
'B': [],
'C': []
}
def make_allowed_move(rod1, rod2):
forward = False
if not rods[rod2]:
forward = True
elif rods[rod1] and rods[rod1][-1] < rods[rod2][-1]:
forward = True
if forward:
print(f'Moving disk {rods[rod1][-1]} from {rod1} to {rod2}')
rods[rod2].append(rods[rod1].pop())
else:
print(f'Moving disk {rods[rod2][-1]} from {rod2} to {rod1}')
rods[rod1].append(rods[rod2].pop())
# display our progress
print(rods, '\n')
def move(n, source, auxiliary, target):
# display starting configuration
print(rods, '\n')
--fcc-editable-region--
# initiate call from source A to target C with auxiliary B
move(NUMBER_OF_DISKS, 'A', 'B', 'C')