219. Tower of Hanoi
EasyRecursion
Move n disks from rod A to rod C using rod B. Print the moves as disk from to, one per line, using the standard recursive solution.
Input format
A single integer n.
Output format
2ⁿ − 1 moves.
Example 1
Input
2
Output
1 A B 2 A C 1 B C
Example 2
Input
1
Output
1 A C
Constraints
1 ≤ n ≤ 10
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…