Back to Freecodecamp

Step 9

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

latest823 B
Original Source

--description--

The Tower of Hanoi puzzle can be solved in 2<sup>n</sup> - 1 moves, where n is the number of disks. Declare a variable named number_of_moves and assign the total number of moves to this variable.

The power operator in Python is **.

--hints--

You should declare a variable named number_of_moves.

js
({ test: () => assert(__userGlobals.has('number_of_moves')) })

The value of number_of_moves should be the expression to calculate the number of moves.

js
({ test: () => {
    assert(runPython(`  
    number_of_moves == 2**NUMBER_OF_DISKS -1      
    `))
} })

--seed--

--seed-contents--

py
--fcc-editable-region--
NUMBER_OF_DISKS = 3

--fcc-editable-region--
rods = {
    'A': list(range(NUMBER_OF_DISKS, 0, -1)),
    'B': [],
    'C': []
}
def move():
    pass