Explanation: Watch this Abdul Bari 9 minute video. Clear, concise and simply explained: https://youtu.be/q6RicK1FCUs?si=25Gh55f-N9DDJqWP


Tower of Hanoi

Difficulty: Medium


Problem Statement

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:

  1. Only one disk can be moved at a time.
  2. You may only move the topmost disk of any peg.
  3. A disk cannot be placed on top of a smaller disk.

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: