Brain-Teaser 509: [Truth and lies]
From The Sunday Times, 14th March 1971 [link]
Alpha, Beta, and Gamma are brothers. One of them always tells the truth, one always lies, and the other sometimes tells the truth and sometimes lies.
I asked Gamma who was the elder of Alpha and Beta. Gamma (who was a little shy) whispered the answer to Alpha who the told me that Gamma had said that Alpha was older than Beta. Beta agreed that he was younger than Alpha, but he warned me that Alpha did not always tell the truth.
The eldest of the three said that Gamma was more honest than Beta, and the youngest agreed with him. Furthermore, the younger of Beta and Gamma said that Alpha always told the truth.
Who is the eldest? And who is the most honest?
This puzzle was originally published with no title.
[teaser509]
Jim Randell 8:51 am on 12 November 2019 Permalink |
This Python program runs in 70ms.
Run: [ @replit ]
from enigma import (subsets, printf) # the possible behaviours: # T tells the truth def T(s): return bool(s) # F lies def F(s): return not s # U is unreliable def U(s): return True # honesty ratings honest = { F: 0, U: 1, T: 2 } # assign behaviours to A, B, G for (fA, fB, fG) in subsets((T, F, U), size=3, select="P"): # "B said A does not always tell the truth" if not fB(fA != T): continue # choose an age ordering for A, B, G for (aA, aB, aG) in subsets((0, 1, 2), size=3, select="P"): # "B said B was younger than A" if not fB(aB < aA): continue # "the younger of B and G said that A always told the truth" if not (fB if aB < aG else fG)(fA == T): continue # "A said that G said that A was older than B" if not fA(fG(aA > aB)): continue # map ages to behaviours m = dict(zip((aA, aB, aG), (fA, fB, fG))) # "the eldest said G was more honest than B" # "the youngest agreed G was more honest than B" s = (honest[fG] > honest[fB]) if not (m[2](s) and m[0](s)): continue # output solution (A, B, G) = (x.__name__ for x in (fA, fB, fG)) (a, b, g) = (["youngest", "middle", "eldest"][x] for x in (aA, aB, aG)) printf("A={A}, {a}; B={B}, {b}; G={G}, {g}")Solution: Alpha is the eldest. Beta is the most honest.
Alpha is the eldest, and sometimes tells the truth and sometimes lies.
Beta is the middle, and always tells the truth.
Gamma is the youngest, and always lies.
LikeLike