After building your mental muscles on Perplexus logic problems, you feel ready to embark on the south sea logic treasure hunt. You travel to remote Uwalahooloo and are initially delighted to discover that you are the first treasure hunter to arrive. Or so you think. It turns out that the other hunters gave up long ago and departed with the natives, having despaired of ever working out which of the two paths through the jungle leads to the treasure and which leads to the deadly sphinx.
Not being someone to give up easily, you search the island and come upon the journal of a previous treasure hunter. You read:
"I've been here for months, but I’ve still reached no clear conclusion as to which path to take. I’ve recorded my findings in the hopes that someone may yet succeed where I have failed.
I have interviewed four natives and know each to be either a knight or a liar. However, as the island is part of an archipelago occupied by two different tribes, I am at a loss to say which language each native speaks (although I have determined that each native is monolingual). I have been able to learn a few interrogatives in both languages, but the confounded thing is that each question has a distinct, valid meaning in each language.
There is also one further complication: one of the natives has a hearing impairment and can't detect a “w” sound at the start of a word.
I list for you the questions and their variant translations in languages A and B:
Wuf?
A: Do more natives speak language A than language B?
B: Are all knights language B speakers?
Hacha?
A:Are there more liars than language A speakers?
B:Would any of the other natives tell me the truth?
Uf?
A:Can I reach the treasure by taking the left path?
B:Is the native with the hearing problem a knight?
The natives' responses (in uppercase letters) to each question were:
Native 1: Wuf? NO Hacha? YES Uf? YES
Native 2: Wuf? YES Hacha? NO Uf? YES
Native 3: Wuf? YES Hacha? YES Uf? NO
Native 4: Wuf? NO Hacha? YES Uf? YES"
(Note that the native with the hearing disability will have misinterpreted the question "Wuf?" as "Uf?")
Can you reason how to choose the correct path?
The program:
DATA ak,al,bk,bl
FOR i = 1 TO 4: READ typ$(i): NEXT
CLS
FOR n1 = 1 TO 4
SELECT CASE typ$(n1)
CASE "ak"
q$(1, 1) = "f": q$(3, 1) = "t": q$(5, 1) = "t"
CASE "al"
q$(1, 1) = "t": q$(3, 1) = "f": q$(5, 1) = "f"
CASE "bk"
q$(2, 1) = "f": q$(4, 1) = "t": q$(6, 1) = "t"
CASE "bl"
q$(2, 1) = "t": q$(4, 1) = "f": q$(6, 1) = "f"
END SELECT
FOR n2 = 1 TO 4
SELECT CASE typ$(n2)
CASE "ak"
q$(3, 2) = "f": q$(5, 2) = "t"
CASE "al"
q$(3, 2) = "t": q$(5, 2) = "f"
CASE "bk"
q$(4, 2) = "f": q$(6, 2) = "t"
CASE "bl"
q$(4, 2) = "t": q$(6, 2) = "f"
END SELECT
FOR n3 = 1 TO 4
SELECT CASE typ$(n3)
CASE "ak"
q$(1, 3) = "t": q$(3, 3) = "t": q$(5, 3) = "f"
CASE "al"
q$(1, 3) = "f": q$(3, 3) = "f": q$(5, 3) = "t"
CASE "bk"
q$(2, 3) = "t": q$(4, 3) = "t": q$(6, 3) = "f"
CASE "bl"
q$(2, 3) = "f": q$(4, 3) = "f": q$(6, 3) = "t"
END SELECT
FOR n4 = 1 TO 4
SELECT CASE typ$(n4)
CASE "ak"
q$(1, 4) = "f": q$(3, 4) = "t": q$(5, 4) = "t"
CASE "al"
q$(1, 4) = "t": q$(3, 4) = "f": q$(5, 4) = "f"
CASE "bk"
q$(2, 4) = "f": q$(4, 4) = "t": q$(6, 4) = "t"
CASE "bl"
q$(2, 4) = "t": q$(4, 4) = "f": q$(6, 4) = "f"
END SELECT
good = 1
REDIM cons$(6)
FOR i = 1 TO 6
IF i <> 4 THEN
FOR spkr = 1 TO 4
IF q$(i, spkr) > "" THEN
IF cons$(i) > "" AND cons$(i) <> q$(i, spkr) THEN good = 0: EXIT FOR
cons$(i) = q$(i, spkr)
END IF
NEXT spkr
END IF
IF good = 0 THEN EXIT FOR
NEXT
IF good THEN
IF cons$(6) = "t" AND RIGHT$(typ$(n2), 1) <> "k" THEN good = 0
IF cons$(6) = "f" AND RIGHT$(typ$(n2), 1) = "k" THEN good = 0
IF cons$(2) = "t" THEN
IF typ$(n1) = "ak" OR typ$(n2) = "ak" OR typ$(n3) = "ak" OR typ$(n4) = "ak" THEN
good = 0
END IF
END IF
FOR spkr = 1 TO 4
IF q$(4, spkr) = "f" THEN
IF RIGHT$(typ$(n1), 1) = "k" AND spkr <> 1 THEN good = 0
IF RIGHT$(typ$(n2), 1) = "k" AND spkr <> 2 THEN good = 0
IF RIGHT$(typ$(n3), 1) = "k" AND spkr <> 3 THEN good = 0
IF RIGHT$(typ$(n4), 1) = "k" AND spkr <> 4 THEN good = 0
END IF
NEXT
IF good THEN
FOR spkr = 1 TO 4
IF q$(4, spkr) = "t" THEN
good = 0
IF RIGHT$(typ$(n1), 1) = "k" AND spkr <> 1 THEN good = 1
IF RIGHT$(typ$(n2), 1) = "k" AND spkr <> 2 THEN good = 1
IF RIGHT$(typ$(n3), 1) = "k" AND spkr <> 3 THEN good = 1
IF RIGHT$(typ$(n4), 1) = "k" AND spkr <> 4 THEN good = 1
END IF
IF good = 0 THEN EXIT FOR
NEXT
END IF
IF good THEN
PRINT typ$(n1); " "; typ$(n2); " "; typ$(n3); " "; typ$(n4); " ";
FOR i = 1 TO 6
IF cons$(i) = "" THEN
PRINT "-";
ELSE
PRINT cons$(i);
END IF
NEXT
END IF
END IF
FOR i = 1 TO 6
q$(i, 4) = ""
NEXT i
NEXT n4
FOR i = 1 TO 6
q$(i, 3) = ""
NEXT i
NEXT n3
FOR i = 1 TO 6
q$(i, 2) = ""
NEXT i
NEXT n2
FOR i = 1 TO 6
q$(i, 1) = ""
NEXT i
NEXT n1
finds:
bk ak al bk fff-tt
meaning
Native 1 speaks B and is a Knight.
Native 2 speaks A and is a Knight.
Native 3 speaks A and is a Liar.
Native 4 speaks B and is a Knight.
The correct answers to the six questions, in the order presented are:
false
false
false
indeterminate (but in fact true for each speaker)
true
true
Since the penultimate question's correct answer is "true", you can indeed reach the treasure by taking the left path.
|
Posted by Charlie
on 2008-02-21 15:42:21 |