# stacks advanced

Hanoi, One Move at a Time

The Tower of Hanoi has ONE law: never place a bigger disk on a smaller one. You're the referee. ⚖️

Disks 1 (smallest) to n (biggest) start stacked on peg a (biggest at the bottom). You get the moves like a>b (move top disk of a to b). Print all legal, or illegal move <k> (1-based) for the FIRST move that grabs from an empty peg or squashes a smaller disk.

Example:

Input: n = 2, moves = ["a>b", "a>c", "b>c"] Output: all legal

Disk 1 moves a→b, disk 2 moves a→c, then disk 1 moves b→c on top of the bigger disk 2 — every move obeys the smaller-on-bigger rule.

💡 need a hint?

stk-hanoi-referee.py🔒 given lines are locked — write your code in between
loading...