On a certain island, there are three tribes - the Whites, the Oranges, and the Lemons which have different standards of veracity. It is not possible to distinguish them otherwise.
Whites are the knights who always tell the truth; Oranges are the liars who always speak falsely. Lemons are knaves who tell the truth and lie alternately, albeit not necessarily in this order.
A visitor was somewhat confused recently when he was introduced to three natives named Mr. White, Mr. Orange, and Mr. Lemon, who belong to the White tribe, the Orange tribe, and the Lemon tribe - albeit not necessarily in this order. There was also a fourth native named Mr.Yellow.
The visitor asked each of the first three natives (a) what his own tribe was, and (b) what was Mr. Yellow's tribe. To these questions, the responses of the three natives was as follows:
Mr. White replied: "I'm not a White. Mr. Yellow is an Orange."
Mr. Orange replied: "I'm not an Orange. Mr. Yellow is a Lemon."
Mr. Lemon replied: "I'm not a Lemon. Mr. Yellow is a White."
To which tribe does Mr. Yellow actually belong?
DECLARE SUB permute (a$)
CLS
' w = truth
' o = liar
' l = knave - alternate
a$ = "wol": h$ = a$ ' for mr. w, mr. o, mr. l
DO
FOR y = 0 TO 2 ' 0=liar, 1=knave, 2=knight
w1 = ABS(MID$(a$, 1, 1) <> "w"): w2 = ABS(y = 0)
o1 = ABS(MID$(a$, 2, 1) <> "o"): o2 = ABS(y = 1)
l1 = ABS(MID$(a$, 3, 1) <> "l"): l2 = ABS(y = 2)
good = 1
IF MID$(a$, 1, 1) = "w" AND (w1 = 0 OR w2 = 0) THEN good = 0
IF MID$(a$, 1, 1) = "o" AND (w1 = 1 OR w2 = 1) THEN good = 0
IF MID$(a$, 1, 1) = "l" AND (w1 = w2) THEN good = 0
IF MID$(a$, 2, 1) = "w" AND (o1 = 0 OR o2 = 0) THEN good = 0
IF MID$(a$, 2, 1) = "o" AND (o1 = 1 OR o2 = 1) THEN good = 0
IF MID$(a$, 2, 1) = "l" AND (o1 = o2) THEN good = 0
IF MID$(a$, 3, 1) = "w" AND (l1 = 0 OR l2 = 0) THEN good = 0
IF MID$(a$, 3, 1) = "o" AND (l1 = 1 OR l2 = 1) THEN good = 0
IF MID$(a$, 3, 1) = "l" AND (l1 = l2) THEN good = 0
IF good THEN PRINT a$, y: PRINT w1; w2, o1; o2, l1; l2
NEXT
permute a$
LOOP UNTIL a$ = h$
reports
low 2
1 0 0 0 1 1
meaning that Mssrs. White, Orange and Lemon, are respectively a Lemon, an Orange and a White.
Mr. White's statements are true and false in that order.
Mr. Orange lies.
Mr. Lemon tells the truth.
Mr. Yellow is a White.
|
Posted by Charlie
on 2014-01-21 16:30:58 |