# Towers of Hanoi Algorithm "Using Auxiliary" Peg

I'm trying to fully understand how the recursive Towers of Hanoi Algorithm works and to implement it in code.

Something that keeps throwing me of is the use of phrases like "move n-1 discs from A to B using C."

I understand that the peg which is referred to is as being "used" is the auxiliary or spare peg, but the language seems misleading because if n-1 has a value of more than 1, then more than one peg is used to perform the move. So the phrase "using C" or "using B" or "using A" doesn't seem accurate and is hindering me from thinking clearly about the problem.

Am I missing something, or can I substitute the phrase "with C as the spare/auxiliary peg" for "using C" without loss of meaning?

I've seen one video where for the n=2 problem, the first move is described as "move a disc from A to B using C" - in this case C isn't involved at all!

I wonder if anyone who has managed to fully grasp the algorithm can advise if it would be helpful to adopt the "using A/B/C" language or if there is another alternative that you have found more helpful, such as my suggestion above - "with C as the spare/auxiliary peg"?

• You can substitute the phrase "with C as the spare/auxiliary peg" for "using C" without loss of meaning. The exact words matter in mathematics less than in other contexts – it's the semantic content of the words that matters. Dec 17 '17 at 22:24
• You can use whatever phrase you like as long as you define it clearly. If you prefer "with C as the spare/auxiliary peg", you're welcome to use it. Others might prefer "as if C were a rainbow" – it doesn't matter as long as we all know what this phrase means. Dec 17 '17 at 22:25
• Finally, you mention that when $n=1$ the extra peg isn't used at all. That's fine – "using C" means that you're allowed to use C, not obligated to. There is a similar difference between mathematical and linguistic or – when mathematicians say "p or q", they also allow the case of both p and q. Dec 17 '17 at 22:27

In mathematics, the literal meaning of a phrase is of little importance. What is important is that both author and reader know what a phrase means, and this can come about in two ways. Either the phrase is well-known, or the phrase is defined in the article. In your case, the phrase "move $n$ pegs from $A$ to $B$ using $C$" means "call the function Hanoi with parameters $n,A,B,C$" - no more, no less. The author could have chosen a completely different phrase, for example "jump from $A$ to $B$ doing $n$ flips above the midpoint $C$", as long as they make it clear that it means "call the function Hanoi with parameters $n,A,B,C$".
Another point that you raise is that when $n=1$, you can move the disc directly from $A$ to $B$, without involving $C$ at all, which you feel contradicts the phrase "using $C$", since $C$ isn't actually used. However, in mathematics such phrases are usually inclusive rather than exclusive — it is not obligatory to actually use $C$. This highlights the fact that mathematical terms often differ in meaning from their common use. For example, when mathematicians say "$p$ or $q$", they are also allowing the possibility "both $p$ and $q$", although common knowledge precludes it.