### turbozone88's blog

By turbozone88, history, 2 months ago,

Tower of Hanoi game is a famous game with discs of different sizes, with a hole in the middle, located on three stakes A, B, C.

The game begins with the state that the disks are stacked on pole A, the small disk is on the large disk, ie the smallest disk is on top, creating a cone shape. The requirement of the game is to transfer all the discs from pole A to pole C, following the following rules:

Only use 3 stakes to transfer.

Only one top disk can be moved at a time from one pole to another.

A disc is only placed on a larger disk.

In this problem, we will have n disks, numbered from 1 to n in order of increasing disk size. Initially, the disks are scattered on three poles but still satisfy the condition that the small disk is on the large disk and the goal is to convert the entire disk into a stack of disks at pole C.

Requirements: Given the state that the disks are on the poles, find a way to convert the entire disk into a stack of disks on pole C.

The first line contains the positive integer n.

The second line contains a string of n characters, the number of which is 'A' or 'B' or 'C' indicating whether disk i is on pole A or pole B or peg C.

limit : n <= 20

Input :  3 AAC

Output :  3 A->B A->C B->C