Teaser 2439: [Higher or lower]
From The Sunday Times, 21st June 2009 [link]
Six cards are numbered 1 to 6. One card is placed on the forehead of each of three expert logicians. Each can see the other numbers, but not his own. I asked each in turn if his number was higher, lower or the same as the average of all three. They replied as follows:
Alf: I don’t know.
Bert: I don’t know.
Charlie: I don’t know.If I now told you the product of the three numbers, you could work out which number each holds.
What numbers did Alf, Bert and Charlie hold (in that order)?
This puzzle was originally published with no title.
I received a message via the “Contact” form asking for a solution to this puzzle.
[teaser2439]
Jim Randell 8:39 am on 15 October 2024 Permalink |
We can start with all possible scenarios – there are P(6, 3) = 120.
Then, knowing A says “don’t know” we can remove any candidates where A would know. For example: if A were to see 1 and 2, he would know that whatever his card is (3, 4, 5, or 6) it would be more than the average of the three cards. Similarly, if he were to see 5 and 6, then he would know that whatever his card was (1, 2, 3, or 4) it would be less than the average of the 3 cards.
This whittles the number of candidates down to 104.
We can then apply the same reasoning to these remaining candidates, knowing that B says “don’t know”, which gets us down to 70 candidates.
Finally applying the same process to these candidates, knowing that C says “don’t know”, gets us down to 22 candidate scenarios.
And only one of the remaining candidates is unique by the product of the numbers. (In fact all the other candidates appear in multiple permutations, so must have repeated products).
This Python program performs these steps. It runs in 71ms. (Internal runtime is 1.8ms).
from enigma import ( irange, compare, seq_all_same, subsets, group, multiply, join, printf ) values = set(irange(1, 6)) # return situations from <ss> where <i> answers "don't know" on seeing <j> and <k> def check(ss, i, j, k): # consider possible situations for s in ss: # find possible candidates from i's POV (same j and k) ts = (t for t in ss if t[j] == s[j] and t[k] == s[k]) # do the candidates give multiple different answers? if not seq_all_same(compare(2 * t[i], t[j] + t[k]) for t in ts): # if so keep this situation yield s # initial list of candidate (A, B, C) assignments ss = set(subsets(values, size=3, select='P')) printf("[start: {n} candidates]", n=len(ss)) # label A, B, C (A, B, C) = (0, 1, 2) # remove candidates that don't give a "don't know" from A ss = set(check(ss, A, B, C)) printf("[after A: {n} candidates]", n=len(ss)) # now remove candidates that don't give a "don't know" from B ss = set(check(ss, B, A, C)) printf("[after B: {n} candidates]", n=len(ss)) # now remove candidates than don't give a "don't know" from C ss = set(check(ss, C, A, B)) printf("[after C: {n} candidates]", n=len(ss)) # group the remaining candidates by product g = group(ss, by=multiply) # look for candidates with a unique product for (p, cs) in g.items(): if len(cs) != 1: continue printf("product = {p} -> {cs}", cs=join(cs, sep=" "))Solution: Alf had 5, Bert had 3, Charlie had 4.
LikeLike
Frits 5:31 am on 25 October 2024 Permalink |
If Bert heard Alf’s answer and Charlie heard Alf’s and Bert’s answer then the reported solution is incorrect (Charlie would say “lower”).
LikeLike
Jim Randell 9:29 am on 25 October 2024 Permalink |
@Frits: I think C would not know whether to say “lower” or “same”, so has to say “don’t know”. (And in the actual situation C’s number is the same as the arithmetic mean, so he cannot know that it is lower).
LikeLike
Frits 11:29 am on 25 October 2024 Permalink |
@Jim, Sorry, I got confused with (5, 4, 3).
LikeLike