Question DSA-REC-0065
HardWhat is the output of this code?
def hanoi(n, a="A", b="B", c="C", moves=None):
if moves is None: moves = []
if n:
hanoi(n - 1, a, c, b, moves)
moves.append(a + c)
hanoi(n - 1, b, a, c, moves)
return moves
m = hanoi(4)
print(len(m), m[7])
- A.
15 AC
- B.
15 BC
- C.
Sign up free to see the answer and a step-by-step explanation.