Explanation: Watch this Abdul Bari 9 minute video. Clear, concise and simply explained: https://youtu.be/q6RicK1FCUs?si=25Gh55f-N9DDJqWP
Difficulty: Medium
You have three pegs: A, B, and C. There are n
disks stacked on peg A in ascending order of size (the smallest disk is on top, and the largest disk is on the bottom). Your task is to move all the disks from peg A to peg C following these rules:
Write a function that accepts an integer n
and returns a list of moves representing the sequence required to solve the Tower of Hanoi puzzle for n
disks.
Each move should be formatted as:
"Move disk X from Y to Z"
Where:
X
= disk number (1 for the smallest, n
for the largest)Y
= source peg (A
, B
, or C
)Z
= destination peg (A
, B
, or C
)