For an odd number of disks: make the legal move between pegs A and C (in either direction make the legal move between pegs A and B (in either direction make the legal move between pegs B and C (in either direction repeat until complete.
A bit with the same value as the previous one means that the corresponding disk is stacked on top the previous disk on the same peg.
Mathematical Ideas (9.).In the Wolfram Language, IntegerExponentRange28 - 1, 2 1 gives moves for the 8-disk puzzle.Define T ( n, r ) displaystyle T(n,r) to be the minimum number of moves required to transfer n disks using r pegs The algorithm can be described recursively: For some k displaystyle k, 1 k n displaystyle 1leq k n, transfer the top.The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: Only one disk can be moved at a time."What is the least number of moves needed to solve the k peg Towers of Hanoi problem?".Let r displaystyle r be the number of pegs.For example, if you started with three pieces, you would move the smallest piece to the opposite end, then continue in the left direction after that.Universum museum in Mexico City, the, tower of Hanoi (also called the, tower of Brahma.Move another disk legally (there will be only one possibility) For the very first move, the smallest disk goes to peg t if h is odd and to peg r if h is even.For example, in an 8-disk Hanoi: Move.Hence disk 0 is the smallest one, and disk h 1 the largest one."Representations in distributed cognitive tasks" (PDF).The edge in the middle of the sides of the largest triangle represents a move of the largest disk.The corner nodes represent the three cases where all the disks are stacked on one peg.If that move is the disk's "natural" move, then the disk has not been moved since the last disk 0 move, and that move should be taken.Counting moves from 1 and identifying the disks by numbers starting from 0 in order of increasing size, the ordinal of the disk to be moved during move m is the number of times m can be divided."Shortest paths in the Tower of Hanoi graph and finite automata".For other variants of the four-peg Tower of Hanoi problem, see Paul Stockmeyer's survey paper.Hence every odd move involves the smallest disk.
If n is odd, the first move is from peg A to peg.
"La quatrieme tour de Hanoi".