Towers of Hanoi

image The Towers of Hanoi is a game that consists of three rods and nn disks of different sizes that can slide onto any rod. The game starts with all the disks stacked in order of size on the left rod, with the biggest disk at the bottom. The aim of the game is to move all the disks from the left rod (rod A) to the right rod (rod C), using the middle rod (rod B) as auxiliary. The moves have to follow these rules:

Write a program to solve the towers of Hanoi, with the minimal number of moves.

Input

A natural number nn between one and ten.

Output

The output corresponds to the content of the three rods at each step, following the format of the example. Write a line with twenty dashes between two steps.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:03:49.048Z

© Jutge.org, 2006–2026.
https://jutge.org