# Tower of Hanoi variation - Split into two towers of odd and even disks

Suppose we have three rods A, B and C, and rod A contains n disks (Exactly like the original Tower of Hanoi problem). The disks are numbered 1 to n, when the bottom disk is number 1 and the top disk is number n.

I want to build two towers: One on rod B which contains only the odd numbered disks and one on rod C which contains only the even numbered disks. The laws of disk moving is exactly like in the original problem.

I am trying to think if it is possible to solve it with only three rods, and if it is how can it be solved recursively.

I thought about moving the top two disks by hand (maybe depends on the parity of n) and then perform a recursive call, but I am not sure at all how to do it.

• In your solution, you said that: "moving top two disks by hand". In the Tower of Hanoi problem, this is not allowed. You can only move one disk at a time. Jan 19, 2022 at 17:39
• @InuyashaYagami For your first comment: I want to build two new towers with all of the disks: the odd disks to B and the even disks to C. For your second comment: I meant to move both disks one a time (maybe in three moves, but I am not sure how). Jan 19, 2022 at 17:47
• Do you want minimum number of moves? Jan 19, 2022 at 17:53
• @InuyashaYagami Not necessarily, a simple recursive algorithm (like the simple and intuitive algorithm for the original problem) is enough. Jan 19, 2022 at 18:05

Let $$T_i$$ be the tower defined by disks: $$i,\dotsc,n$$.

Here is a simple recursive algorithm:

Initialize i := 1
while(i != n+1)
If i is even:
move the tower T(i+1) on any rod other than C using the standard Tower of Hanoi algorithm.
move disk i to rod C
else:
move the tower T(i+1) on any rod other than B using the standard Tower of Hanoi algorithm.
move disk i to rod B
i <- i+1
end

• Note that in this case, for $i < j$, disk $i$ is smaller than disk $j$. However, I think that makes the algorithm easier to write than in the case of the original post where disk $1$ was the largest. Jan 19, 2022 at 18:29
• @Nathaniel right. I have edited the answer. Thanks! Jan 19, 2022 at 18:31