Tower of Hanoi

00:00
EasyRecursionDivide & Conquer
TCSWipro

Move n disks from source peg to destination peg using auxiliary peg. Smaller disk must always be on top. Print each move.

Examples

Input → n=1
Output → 'Move disk 1: A→C'
Input → n=2
Output → 3 moves: A→B, A→C, B→C
Input → n=3
Output → 7 moves printed