Brain-Teaser 479: [Sixpences]
From The Sunday Times, 2nd August 1970 [link]
My nephew Anselm collects good old-fashioned sixpences in a good old-fashioned piggy bank. These he recently extracted to audit and, while experimenting by putting them into two or more equal piles of two or more coins, found that there were exactly six different ways in which this could be done.
From one of these combinations he returned one pile to the bank, and found that the balance could again be distributed into equal piles in exactly six different ways. On this second occasion he returned two equal piles from one of the combinations to the bank, and again found that the balance could be distributed into equal piles in six different ways only. He conducted this experiment a total of seven times, on the third occasion returning three piles, on the fourth four piles and so on, and after the seventh found that he had 24 sixpences remaining.
On none of these occasions did he deposit as much as 25s. in the bank. His third deposit was twice as much as his sixth, and three times as much as his second. His fifth deposit was five times as large as his first.
How many sixpences had he saved up?
I have modified the wording slightly to clarify the puzzle.
This puzzle was originally published with no title.
[teaser479]
Jim Randell 12:59 pm on 7 May 2019 Permalink |
I assumed that making one pile with all the coins in does not count (as there are no solutions if it does count as one of the six configurations).
1s = 12d, so at no point does Anselm deposit more than 52 coins. So he cannot start with more than (24 + 7×52 = 388) coins. This gives us a bounded solution space to search in, but it is more interesting to run the process backwards starting with the 24 final coins.
This Python 3 program works backwards recursively to solve the problem. It runs in 79ms.
from enigma import (divisors, div, printf) # possible pile sizes for n coins piles = lambda n: list(p for p in divisors(n) if 1 < p < n) # work backwards from <n> coins and <i> piles deposited to 1 pile deposited # i = number of piles deposited # n = number of coins # ps = possible pile sizes # return [(<n coins>, <n piles>), ...] def solve(n, i, ps, ss=[]): if i == 0: yield ss else: # consider the number of coins in each pile for k in ps: # i equally sized piles were deposited in the bank d = i * k # but not more than 52 coins if d > 52: break # the total number of coins before the deposit t = n + d # and t must have 6 possible piles numbers ds = piles(t) if not (len(ds) == 6): continue yield from solve(t, i - 1, ds, [(t, k)] + ss) # we end up with 24 coins N = 24 for ss in solve(N, 7, piles(N) + [N]): # calculate the numbers of coins returned to the bank at each stage ds = list(i * k for (i, (_, k)) in enumerate(ss, start=1)) # 3rd deposit was twice the 6th and 3 times the 2nd if not (ds[2] == 2 * ds[5] == 3 * ds[1]): continue # 5th deposit was 5 times the 1st if not (ds[4] == 5 * ds[0]): continue # output solution for (i, ((t, k), d)) in enumerate(zip(ss, ds), start=1): printf("{i}: {t} coins in {p} piles of {k}; deposit {i} piles = {d} coins", p=div(t, k)) printf("started with {n} coins; finished with {N} coins", n=ss[0][0]) printf()Solution: Anselm has 138 sixpences.
LikeLiked by 1 person