The birthdays of the five friends Al, Ben, Cal, Dan, and Ethan falls on the same day, though they are different ages.
On their mutual birthday, the five friends were discussing their respective current ages. The discussion was as follows:
Dan said to Ben: "I'm nine years older than Ethan."
Ethan said to Ben: "I'm seven years older than Al."
Al said to Ben: "Your age is exactly 1.7 times that of mine."
Ben said to Cal: "Ethan is younger than you."
Cal said to Dan: "The difference between our ages is six years."
Cal said to Al: "I'm ten years older than you."
Cal said to Al: "Ben is younger than Dan."
Ben said to Cal: "The difference between your age and Dan's is the
same as the difference between Dan's and Ethan's."
It is known that when one of them spoke to someone older, everything they said was true. However, when speaking to someone younger, everything they said was false.
What are the current ages of each person?
DECLARE SUB permute (a$)
CLS
a$ = "abcde": h$ = a$
DO
a = INSTR(a$, "a")
b = INSTR(a$, "b")
c = INSTR(a$, "c")
d = INSTR(a$, "d")
e = INSTR(a$, "e")
good = 1
IF d < b THEN IF d < e THEN good = 0
IF b < c THEN IF e > c THEN good = 0
IF a > c THEN good = 0
IF b < d THEN good = 0
IF b < c THEN
IF SGN(e  d) <> SGN(d  c) THEN good = 0
END IF
IF good THEN PRINT a$
permute a$
LOOP UNTIL a$ = h$
The program disregards specific references to differences in age, and so can produce only a list of eligible orders, from youngest to oldest:
acedb
aecdb
aedbc
aedcb
eacdb
eadbc
eadcb
edabc
edacb
edbac
Dan is younger than Ben in all these scenarios, so Dan is indeed 9 years older than Ethan by statement 1.
Ethan is younger than Ben and is thus 7 years older than Al. This reduces the order possibilities to
acedb
aecdb
aedbc
aedcb
So Al is younger than Ben and Ben is indeed 1.7 times Al's age.
Cal of course is older than Al, but not by the exact ten years he claimed.
C order
A B E D if B<C if C<D if B<C if C<D if order is aedcb
10 17 17 26 35
20 34 27 36 45 30 aebdc aecbd
30 51 37 46 55 40 aedbc * aecdb * 46 < C < 51 *
40 68 47 56 65 x 50
The first row is impossible, with two ages of 17.
The x against 65 for C is a contradiction of the columntitle assumption, and thus a contradiction.
The orders marked * are within the list of possibilities.
Let's check the possibilities:
A=30
E=37
D=46
B=51
C=55
A=30
E=37
C=40 This set contradicts Ben lying (as older) to Cal
D=46 saying Ethan is younger than Cal.
B=51
A=30
E=37 This set contradicts Ben lying (as older) to Cal
D=46 saying Ethan is younger than Cal.
C={47 .. 50}
B=51
Al is 30.
Ethan is 37.
Dan is 46.
Ben is 51.
Cal is 55.

Posted by Charlie
on 20130910 17:33:12 