1#include <bits/stdc++.h>
2using namespace std;
3
4// Classic recursive Tower of Hanoi.
5// Move n disks from peg 'from' to peg 'to' using 'via' as helper.
6void hanoi(int n, char from, char to, char via,
7 vector<string>& moves) {
8 if (n == 0) return;
9 hanoi(n - 1, from, via, to, moves);
10 moves.push_back(string("Move disk ") + to_string(n) +
11 ": " + from + " -> " + to);
12 hanoi(n - 1, via, to, from, moves);
13}
14
15vector<string> solveHanoi(int n) {
16 vector<string> moves;
17 hanoi(n, 'A', 'C', 'B', moves);
18 return moves; // total = 2^n - 1 moves
19}