Back to Freecodecamp

Step 14

curriculum/challenges/english/blocks/learn-recursion-by-solving-the-tower-of-hanoi-puzzle/64df72c6e0183a191fcd72dc.md

latest656 B
Original Source

--description--

Before your function call, write a comment saying initiate call from source A to target C with auxiliary B.

--hints--

You should write the given comment before your function call.

js
({test: () => assert.match(code, /#\s*initiate\scall\sfrom\ssource\sA\sto\starget\sC\swith\sauxiliary\sB/) })

--seed--

--seed-contents--

py
NUMBER_OF_DISKS = 3
number_of_moves = 2**NUMBER_OF_DISKS - 1
rods = {
    'A': list(range(NUMBER_OF_DISKS, 0, -1)),
    'B': [],
    'C': []
}

def move(n, source, auxiliary, target):
    print(rods)
--fcc-editable-region--

move(NUMBER_OF_DISKS, 'A', 'B', 'C')
--fcc-editable-region--