There is an ambiguity in the question, as to whether a liar might be able to claim to be younger than herself, so the following program was written to find examples where there were 10 non-self-referential possible such claims (to which the two liars statements about themselves could be added to make 12), and examples where there were 12 non-self-referential claims like that.
After finding each combination of two liars out of five age positions that causes either 10 or 12 non-self-referential claims of "I am younger than x", the program goes through all 5! = 120 permutations of A through E being assigned to ages 1 through 5 (proxy for the unknown ages). When such an assignment matches the set of the 10 known statements, it is reported as the sequence of initials from youngest to oldest.
DECLARE SUB permute (a$)
CLS
FOR liar1 = 1 TO 4
FOR liar2 = liar1 + 1 TO 5
ct = 0
FOR x = 1 TO 5
FOR y = 1 TO 5
IF x <> y THEN
IF x < y AND x <> liar1 AND x <> liar2 THEN ct = ct + 1
IF x > y AND (x = liar1 OR x = liar2) THEN ct = ct + 1
END IF
NEXT
NEXT
PRINT liar1; liar2, ct
IF ct = 10 OR ct = 12 THEN
pr$ = ""
FOR x = 1 TO 5
FOR y = 1 TO 5
IF x <> y THEN
IF x < y AND x <> liar1 AND x <> liar2 OR x > y AND (x = liar1 OR x = liar2) THEN
PRINT LTRIM$(STR$(x)); LTRIM$(STR$(y)); " ";
pr$ = pr$ + LTRIM$(STR$(x)) + LTRIM$(STR$(y)) + " "
END IF
END IF
NEXT
NEXT
PRINT
a$ = "abcde": h$ = a$
DO
as$ = LTRIM$(STR$(INSTR(a$, "a")))
bs$ = LTRIM$(STR$(INSTR(a$, "b")))
cs$ = LTRIM$(STR$(INSTR(a$, "c")))
ds$ = LTRIM$(STR$(INSTR(a$, "d")))
es$ = LTRIM$(STR$(INSTR(a$, "e")))
good = 1
IF INSTR(pr$, bs$ + es$) = 0 THEN good = 0
IF INSTR(pr$, cs$ + as$) = 0 THEN good = 0
IF INSTR(pr$, cs$ + bs$) = 0 THEN good = 0
IF INSTR(pr$, cs$ + ds$) = 0 THEN good = 0
IF INSTR(pr$, cs$ + es$) = 0 THEN good = 0
IF INSTR(pr$, ds$ + bs$) = 0 THEN good = 0
IF INSTR(pr$, ds$ + cs$) = 0 THEN good = 0
IF INSTR(pr$, ds$ + es$) = 0 THEN good = 0
IF INSTR(pr$, es$ + as$) = 0 THEN good = 0
IF INSTR(pr$, es$ + ds$) = 0 THEN good = 0
IF good THEN PRINT a$
permute a$
LOOP UNTIL h$ = a$
END IF
PRINT
NEXT
NEXT
1 2 4
1 3 6
1 4 8
1 5 10
23 24 25 34 35 45 51 52 53 54
2 3 8
2 4 10
12 13 14 15 21 34 35 41 42 43
2 5 12
12 13 14 15 21 34 35 45 51 52 53 54
3 4 12
12 13 14 15 23 24 25 31 32 41 42 43
cebda
3 5 14
4 5 16
For example, the line 1 2 4 shows that if the youngest two were liars, only 4 statements of that form would be possible: 4 truthfully about 5, 3 truthfully about 4 and 5, and 2 falsely about 1.
In the cases where 10 such statements were possible, no assignment of names (letters) to digits would produce a set or subset that matched what was given.
The results also show that only one of the two sets of 12 statements works: only the sequence Carol (youngest), Emily, Brenda, Diane, Abby (oldest), with Brenda (3) and Diane (4) as the liars.
Emily's claiming to be younger than Brenda and Brenda's claim to be younger than Carol are the two statements that were left out of the puzzle clues, one true and one false.
Based on Enigma No. 1480, "Getting older", by Susan Denham, New Scientist, 9 February 2008. |