The land of Kivel is populated by 4 types of people:
Knights: always tell the truth;
Liars: always tell lies;
Knaves: each of a knave's statements strictly alternate truth and lies;
Transposers: a transposer's statements are always of opposite truthvalue to the
previous statement most recently made by anyone, including himself or herself.
If no one has made a statement yet, a transposer will speak truth or a lie
randomly for the first statement.
Scientists have discovered that in Kivelians, veracity is an inherited characteristic based on blood type. Any individual has one of six possible genotypes (KK, KO, LL, LO, KL, and OO) that produce one of four possible phenotypes:
Knight (produced by KK homozygous and KO heterozygous genotypes),
Liar (produced by LL homozygous and LO heterozygous genotypes),
Knave (produced by the KL heterozygous genotype), and
Transposer (produced by the OO homozygous genotype).
If April, Baxter, Celeste, and Douglass, are a knight, a liar, a knave, and a transposer, in some order; and if each one is a parent or child to at least one other person in the group, can you determine each person's type, and relation to the others, given the statements below?
April: I am heterozygous.
Baxter: I am a knight.
Celeste: Douglass is April's father.
Douglass: I am heterozygous.
Baxter: Douglass is not my father.
April: Baxter is a knave.
Baxter: Celeste is April's mother.
Celeste: The liar among us is homozygous.
Douglass: Baxter is my son.
Celeste: Baxter is my son.
April: There are exactly two heterozygous and two homozygous among us.
Baxter: The liar among us is heterozygous.
Celeste: April is heterozygous.
Douglass: I am related by blood to exactly two of the others here.
April: Douglass is heterozygous.
Douglass: The knight among us is homozygous.
Notes: You may find it helpful to use Punnett Squares to test which types of parents can produce which types of children. Here's an example of a Punnett Square using blood types.
Also, the spacing is given only for readability. You may assume the comments are all said in order, with no breaks between them.
DECLARE FUNCTION checkPoss! (parent$, child$)
DIM typ$(7), typ(7), used(4)
DATA kk,ko,ll,lo,kl1,kl2,oo
DATA 1,1,2,2,3,3,4
FOR i = 1 TO 7: READ typ$(i): NEXT
FOR i = 1 TO 7: READ typ(i): NEXT
PRINT
'kl1 is knave starting with truth; kl2 is knave starting with lie
FOR a = 1 TO 7
atyp$ = typ$(a)
atval = typ(a)
IF used(atval) = 0 THEN
used(atval) = 1
FOR b = 1 TO 7
btyp$ = typ$(b)
btval = typ(b)
IF used(btval) = 0 THEN
used(btval) = 1
FOR c = 1 TO 7
ctyp$ = typ$(c)
ctval = typ(c)
IF used(ctval) = 0 THEN
used(ctval) = 1
FOR d = 1 TO 7
dtyp$ = typ$(d)
dtval = typ(d)
IF used(dtval) = 0 THEN
used(dtval) = 1
good = 1
'group 1
IF LEFT$(atyp$, 1) <> MID$(atyp$, 2, 1) THEN ahet = 1: ELSE ahet = 0
IF atval = 1 OR atyp$ = "kl1" THEN tr = 1: ELSE tr = 0
IF ahet = 1 AND tr = 0 OR ahet = 0 AND tr = 1 THEN good = 0
IF atval = 4 THEN good = 1: tr = 1  tr
IF good THEN
IF btyp$ = "kl1" OR btval = 4 AND tr = 0 THEN good = 0
IF btval = 1 THEN tr = 1: ELSE tr = 0
IF good THEN
IF ctval = 1 OR ctyp$ = "kl1" OR ctval = 4 AND tr = 0 THEN DfatA = 1: tr = 1: ELSE DfatA = 0: tr = 0
IF DfatA THEN good = checkPoss(dtyp$, atyp$)
IF good THEN
IF LEFT$(dtyp$, 1) <> MID$(dtyp$, 2, 1) THEN dhet = 1: ELSE dhet = 0
IF dtval = 1 OR dtyp$ = "kl1" OR dtval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
IF dhet = 1 AND tr = 0 OR dhet = 0 AND tr = 1 THEN good = 0
'group 2
IF good THEN
IF btval = 1 OR btyp$ = "kl2" OR btval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
DfatB = 1  tr
IF DfatB THEN good = checkPoss(dtyp$, btyp$)
IF good THEN
IF atval = 1 OR atyp$ = "kl2" OR atval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
IF btval = 3 AND tr = 0 OR btval <> 3 AND tr = 1 THEN good = 0
IF good THEN
IF btval = 1 OR btyp$ = "kl1" OR btval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
CmotA = tr
IF CmotA THEN good = checkPoss(ctyp$, atyp$)
IF good THEN
IF ctval = 1 OR ctyp$ = "kl2" OR ctval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
lhom = 0
IF atyp$ = "ll" THEN lhom = 1
IF btyp$ = "ll" THEN lhom = 1
IF ctyp$ = "ll" THEN lhom = 1
IF dtyp$ = "ll" THEN lhom = 1
IF tr <> lhom THEN good = 0
'group 3
IF good THEN
IF dtval = 1 OR dtyp$ = "kl2" OR dtval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
IF tr <> DfatB THEN good = 0
IF good THEN
IF ctval = 1 OR ctyp$ = "kl1" OR ctval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
CmotB = tr
IF CmotB THEN good = checkPoss(ctyp$, btyp$)
IF good THEN
IF atval = 1 OR atyp$ = "kl1" OR atval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
hetct = 0
IF LEFT$(atyp$, 1) <> MID$(atyp$, 2, 1) THEN hetct = hetct + 1
IF LEFT$(btyp$, 1) <> MID$(btyp$, 2, 1) THEN hetct = hetct + 1
IF LEFT$(ctyp$, 1) <> MID$(ctyp$, 2, 1) THEN hetct = hetct + 1
IF LEFT$(dtyp$, 1) <> MID$(dtyp$, 2, 1) THEN hetct = hetct + 1
IF tr = 1 AND hetct <> 2 OR tr = 0 AND hetct = 2 THEN good = 0
IF good THEN
IF btval = 1 OR btyp$ = "kl2" OR btval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
IF tr = lhom THEN good = 0
'group 4
IF good THEN
IF ctval = 1 OR ctyp$ = "kl2" OR ctval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
IF ahet <> tr THEN good = 0
IF good THEN
' skipping to April
IF atval = 1 OR atyp$ = "kl2" OR atval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
IF dhet <> tr THEN good = 0
IF good THEN
IF dtval = 1 OR dtyp$ = "kl2" OR dtval = 4 AND tr = 0 THEN tr = 1: ELSE tr = 0
khom = 0
IF atyp$ = "kk" THEN khom = 1
IF btyp$ = "kk" THEN khom = 1
IF ctyp$ = "kk" THEN khom = 1
IF dtyp$ = "kk" THEN khom = 1
IF tr <> khom THEN good = 0
IF good THEN
PRINT atyp$; btyp$; ctyp$; dtyp$; " "; DfatA; DfatB; CmotA; CmotB
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
used(dtval) = 0
END IF
NEXT
used(ctval) = 0
END IF
NEXT
used(btval) = 0
END IF
NEXT
used(atval) = 0
END IF
NEXT
END
FUNCTION checkPoss (parent$, child$)
good = 0
FOR i = 1 TO 2
IF INSTR(child$, MID$(parent$, i, 1)) THEN good = 1: EXIT FOR
NEXT
checkPoss = good
END FUNCTION
finds
kl1ookoll 1 0 1 1
meaning
Alice is a KL knave telling the truth on her first statement.
Baxter is an OO transposer.
Celeste is a KO knight.
Douglass is an LL liar.
Douglass is Alice's father, but not Baxter's.
Celeste is mother to both Alice and Baxter.
The program did not evaluate Douglass's nexttolast statement, but as he is a liar, he's not related by blood to exactly two of the other three, and that is consistent with his LL genotype, with only one L allele among the other participants.
T April: I am heterozygous.
F Baxter: I am a knight.
T Celeste: Douglass is April's father.
F Douglass: I am heterozygous.
T Baxter: Douglass is not my father.
F April: Baxter is a knave.
T Baxter: Celeste is April's mother.
T Celeste: The liar among us is homozygous.
F Douglass: Baxter is my son.
T Celeste: Baxter is my son.
T April: There are exactly two heterozygous and two homozygous among us.
F Baxter: The liar among us is heterozygous.
T Celeste: April is heterozygous.
F Douglass: I am related by blood to exactly two of the others here.
F April: Douglass is heterozygous.
F Douglass: The knight among us is homozygous.

Posted by Charlie
on 20120209 18:12:55 