debug = false; int tower(int to_move, string source, string dest, string temp) { if (to_move > 0) { if (debug) { print("move a disc from ", source, " to ", dest, "\n"); } a = tower(to_move - 1, source, temp, dest); b = tower(to_move - 1, temp, dest, source); return a + b + 1; } else { return 0; } } for (i = 1; i < 10; i++) { moves = tower(i, "left", "right", "center"); if (moves != 2 ** i - 1) exit(1); }