From The Sunday Times, 30th May 1971 [link]
“What’s inside it?” asked the Mole wriggling with curiosity.
“There’s cold chicken inside it”, replied the Rat briefly: “cold-tongue-cold-ham-cold-beef-pickled-gherkins-salad-french-rolls-cress-sandwiches-potted-meat-ginger-beer-lemonade-soda-water…”
“Oh, stop”, cried the Mole in ecstasies. “This is too much for one picnic. We can have another tomorrow on what’s left”.
“Do you really think so?” inquired the Rat seriously. “Let’s see. There’s only salad-pickled-gherkins-french-rolls-and-soda-water enough for two days: so if we have ham today we’ll have beef tomorrow; if we have potted meat today we’ll have cress sandwiches tomorrow; and if we have tongue today we’ll have lemonade tomorrow”.
“If we save the cress sandwiches for tomorrow we’ll have the beef today; if we keep the potted meat for tomorrow we’ll have the ginger beer today; and if we keep the lemonade for tomorrow we’ll have the ham today”. The Mole was entering into the spirit of the thing.
“In any event we’ll have the lemonade and ginger beer on different days, and likewise the beef and the chicken”, Rat shrieked excitedly.
“And if we have the chicken and cress sandwiches together, we’ll have the potted meat the day after we have the tongue”. The Mole rolled on his back at the prospect. “And we’ll eat every scrap”.
Which of the eight items did they save for the second day?
This puzzle was originally published with no title.
[teaser520]
Jim Randell 12:54 pm on 28 May 2020 Permalink |
The puzzle text doesn’t include the usual alphametic caveat that different letters stand for different digits, only that the digits are replaced consistently by letters (i.e. the same letter is replaced by the same digit). And if there are zero digits involved the 24 rearrangements of the 4 digits of TIME will include some sequences which don’t give 4 valid digit numbers.
So this Python program considers all 4 digit values for TIME, and totals only those rearrangements corresponding to 4 digit numbers. It runs in 135ms.
Run: [ @repl.it ]
from enigma import (irange, nsplit, nconcat, subsets, ordered, cached, printf) # update a map m consistently with (k, v) pairs in ps def update(m, ps): m = m.copy() for (k, v) in ps: x = m.get(k) if x is None: m[k] = v elif x != v: return None return m # sum the rearrangements that give 4 digit numbers @cached def total(ds): t = 0 for s in subsets(ds, size=len, select="mP"): if s[0] != 0: t += nconcat(s) return t # consider 4 digit numbers for TIME for TIME in irange(1000, 9999): # this maps the letters T, I, M, E to digits ds = nsplit(TIME, 4) # sum the rearrangements of TIME that give 4 digit numbers t = total(ordered(*ds)) # the total is a 6 digit number ts = nsplit(t) if len(ts) != 6: continue # map letters to digits m = update(dict(zip("TIME", ds)), zip("LITTLE", ts)) if m is None: continue # output solution printf("TIME={TIME} LITTLE={t}")Solution: TIME = 3578.
And so LITTLE = 153318.
It turns out that using a standard alphametic interpretation, and not worrying about whether the rearrangements always give 4 digit numbers will also give this answer. So:
If we write down the sum of the 24 permutations of TIME, each letter appears in each column 6 times, the result of the sum is thus:
Which we can solve as an alphametic expression using the [[
SubstitutedExpression()]] solver from the enigma.py library.The following run file gives the same solution in 92ms.
LikeLike
GeoffR 8:47 am on 29 May 2020 Permalink |
Easy to check the digits in TIME give the digits in LITTLE
little, cnt = 0, 0 # check value of LITTLE using TIME'S digits of (3,5,7,8) from itertools import permutations for p in permutations((3,5,7,8)): t, i, m, e = p time = 1000*t + 100*i + 10*m + e # Add current <time> total little += time # increase permutation count cnt += 1 print(f"LITTLE = {little} in {cnt} permutations") # LITTLE = 153318 in 24 permutationsLikeLike