The owner of the mansion has been murdered. The visitors to the mansion were Allen, Bixby, and Crain.
- The murderer, who was one of the three visitors, arrived at the mansion later than at least one of the other two visitors.
- A detective, who was one of the three visitors, arrived at the mansion earlier than at least one of the other two visitors.
- The detective arrived at the mansion at midnight.
- Neither Allen nor Bixby arrived at the mansion after midnight.
- The earlier arriver of Bixby and Crain was not the detective.
- The later arriver of Allen and Crain was not the murderer.
Who was the murderer?
DECLARE SUB permute (a$)
arr$ = "abc": h$ = arr$
FOR murd = 2 TO 3 'order of arrival
FOR det = 1 TO 2
bm$ = LEFT$(arr$, det - 1)
am$ = MID$(arr$, det + 1)
good = 1
IF INSTR(am$, "a") > 0 OR INSTR(am$, "b") > 0 THEN good = 0
b = INSTR(arr$, "b")
c = INSTR(arr$, "c")
IF b < c THEN early = b: ELSE early = c
IF early = det THEN good = 0
a = INSTR(arr$, "a")
IF a > c THEN late = a: ELSE late = c
IF late = murd THEN good = 0
IF good THEN PRINT arr$, murd; det
LOOP UNTIL arr$ = h$
bac 2 2
meaning they arrived in the order Bixby, Allen, Crain, and that both the murderer and the detective were (was) the second to arrive: Allen.
So Allen was the murderer (and also the detective).
Posted by Charlie
on 2013-01-24 13:33:52