Brain-Teaser 520: [Picnic allocations]
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:10 pm on 26 May 2020 Permalink |
The following Python program checks all possible assignments of days to the 8 items in question, and then checks to find which assignments satisfy all the conditions.
It runs in 71ms (on my new laptop). (Internal runtime is 192µs).
from enigma import (subsets, implies, printf) # choose days for the 8 items in question for (CC, CT, CH, CB, CS, PM, GB, LE) in subsets((1, 2), size=8, select="M"): # check the statements: # R: "if we have ham today we'll have beef tomorrow" if not implies(CH == 1, CB == 2): continue # R: "if we have potted meat today we'll have cress sandwiches tomorrow" if not implies(PM == 1, CS == 2): continue # R: "if we have tongue today we'll have lemonade tomorrow" if not implies(CT == 1, LE == 2): continue # M: "if we save the cress sandwiches for tomorrow we'll have the beef today" if not implies(CS == 2, CB == 1): continue # M: "if we keep the potted meat for tomorrow we'll have the ginger beer today" if not implies(PM == 2, GB == 1): continue # M: "if we keep the lemonade for tomorrow we'll have the ham today" if not implies(LE == 2, CH == 1): continue # R: "we'll have the lemonade and ginger beer on different days ..." if not (LE != GB): continue # R: "... and likewise the beef and the chicken" if not (CB != CC): continue # M: "if we have the chicken and cress sandwiches together, we'll # have the potted meat the day after we have the tongue" if not implies(CC == CS, PM == CT + 1): continue # output solution printf("CC={CC} CT={CT} CH={CH} CB={CB} CS={CS} PM={PM} GB={GB} LE={LE}")Solution: The cold beef, potted meat and lemonade was saved for the second day.
LikeLike
John Crabtree 8:10 pm on 25 June 2020 Permalink |
There are 9 statements for 8 unknowns. If Ch is true for chicken today, and ~Ch is true for chicken tomorrow,then the statements may be written as boolean equations:
1. H.~B + ~H = 1
2. P.~Cr + ~P = 1
3. T.~L + ~T = 1
4. ~Cr.B + Cr = 1
5. ~P.G + P = 1
6. ~L.H + L = 1
7. L XOR G
8. B XOR Ch
9. [(Ch XNOR Cr).~P.T] + (Ch XOR Cr) = 1
Combining equations 5, 7, 6, 1, 4, 2 and 8 gives
1 = (~P.G + P).( L XOR G).(~L.H + L).(H.~B + ~H).(~Cr.B + Cr).(P.~Cr + ~P).(B XOR Ch)
= ~P.G.( L XOR G).(~L.H + L).(H.~B + ~H).(~Cr.B + Cr).(P.~Cr + ~P).(B XOR Ch) +
….P.(P.~Cr + ~P).(~Cr.B + Cr).(H.~B + ~H).(~L.H + L).( L XOR G).(B XOR Ch)
= ~P.G.~L.H.~B.Cr.Ch + P.~Cr.B.~H.L.~G.~Ch
Combing this with equation 9 gives ~P.G.~L.H.~B.Cr.Ch.T = 1
Equation 3 is satisfied, but is not required to solve the teaser by this method
The items to be saved for tomorrow are given by ~B,~L and ~P, ie cold Beef, Lemonade and Potted meat.
Starting with any assumption other than T or ~T and working through the equations 1-2, and 4-8 in some order and finally 9 gives either a consistent solution,or a contradiction (reductio ad absurdum). If one starts by assuming T, then equation 3 is used before the others. If ~T is assumed, then equation 9 gives Ch.~Cr + ~Ch.Cr = 1, and both conditions have to be checked to show that ~T is not true
LikeLike
Jim Randell 3:12 pm on 15 November 2025 Permalink |
Or using the [[
SubstitutedExpression]] solver from the enigma.py library.The code generated from the following run file has an internal runtime of 75µs.
#! python3 -m enigma -rr SubstitutedExpression --distinct="" --digits="1,2" --macro="@CC = {A}" # cold chicken --macro="@CT = {B}" # cold tongue --macro="@CH = {C}" # cold ham --macro="@CB = {D}" # cold beef --macro="@CS = {E}" # cress sandwiches --macro="@PM = {F}" # potted meat --macro="@GB = {G}" # ginger beer --macro="@LE = {H}" # lemonade # R: "if we have ham today we'll have beef tomorrow" "implies(@CH == 1, @CB == 2)" # R: "if we have potted meat today we'll have cress sandwiches tomorrow" "implies(@PM == 1, @CS == 2)" # R: "if we have tongue today we'll have lemonade tomorrow" "implies(@CT == 1, @LE == 2)" # M: "if we save the cress sandwiches for tomorrow we'll have the beef today" "implies(@CS == 2, @CB == 1)" # M: "if we keep the potted meat for tomorrow we'll have the ginger beer today" "implies(@PM == 2, @GB == 1)" # M: "if we keep the lemonade for tomorrow we'll have the ham today" "implies(@LE == 2, @CH == 1)" # R: "we'll have the lemonade and ginger beer on different days ..." "@LE != @GB" # R: "... and likewise the beef and the chicken" "@CB != @CC" # M: "if we have the chicken and cress sandwiches together, we'll # have the potted meat the day after we have the tongue" "implies(@CC == @CS, @PM == @CT + 1)" # output day for each dish --template="CC=@CC CT=@CT CH=@CH CB=@CB CS=@CS PM=@PM GB=@GB LE=@LE" --solution="" --verbose="1-H"LikeLike