Teaser 3221: Faulty towers
From The Sunday Times, 16th June 2024 [link] [link]
The famous “Tower of Hanoi” puzzle consists of a number of different-sized rings in a stack on a pole with no ring above a smaller one. There are two other poles on which they can be stacked and the puzzle is to move one ring at a time to another pole (with no ring ever above a smaller one) and to end up with the entire stack moved to another pole.
Unfortunately I have a faulty version of this puzzle in which two of the rings are of equal size. The minimum number of moves required to complete my puzzle (the two equal rings may end up in either order) consists of four different digits in increasing order.
What is the minimum number of moves required?
[teaser3221]

Jim Randell 4:52 pm on 14 June 2024 Permalink |
See also: Teaser 1858 and Enigma 14.
I re-used the
H()function from Teaser 1858 to calculate the number of moves required for a configuration of discs.This Python program runs in 65ms. (Internal runtime is 421us).
Run: [ @replit ]
from enigma import (Accumulator, irange, inf, nsplit, is_increasing, printf) # number of moves for sequence of discs (largest to smallest) def H(ns): t = 0 m = 1 for n in ns: t += m * n m *= 2 return t # consider numbers of different size discs for n in irange(1, inf): r = Accumulator(fn=min) # duplicate one of the discs for i in irange(n): ns = [1] * n ns[i] += 1 # calculate the number of moves t = H(ns) # answer is a 4 digit number consisting of strictly increasing digits if 999 < t < 10000 and is_increasing(nsplit(t), strict=1): printf("{ns} -> {t}") r.accumulate(t) if r.value >= 6789: breakSolution: The minimum number of moves required is 1279.
The arrangement of discs is:
There are 11 discs (of 10 different sizes) and discs 9 and 10 (counting from the bottom) are the same size.
So the number of moves is:
With analysis:
The number of moves for a standard “Tower of Hanoi”, is the sum of the powers of 2 corresponding to each disc.
So for a tower of 4 discs we would have:
When one of the discs is duplicated we also duplicate one of the powers of 2, and this gives us a 4-digit increasing number (the smallest is 1234, and the largest 6789).
So our starting tower must have between 10 and 12 different sizes.
Summing the first n powers of 2:
And we need to duplicate one of the powers of 2 to give a number with (strictly) increasing digits:
LikeLike