There are precisely three brothers in the Pearson family and exactly three brothers in the Turner family.
Three of these six men are Knights, who always tell the truth; and three are liars, who always speak falsely. Neither set of 3 brothers from the two families consist exclusively of liars.
They made the following statements:
- Abner: "Both of my brothers are liars."
- Benny: "Both of my brothers are knights."
- Connor: "Abner and Benny are both liars."
- Damian: "Connor and I are brothers."
- Eldon: "Benny and I are brothers."
- Freddy: "Eldon tells the truth."
- Freddy: "Benny belongs to the Pearson family."
Determine the full names of the six men, and ascertain their types.
clc, clearvars
fam='pppttt';
fams=unique(perms(fam),'rows');
type='lllkkk';
types=unique(perms(type),'rows');
% first member of each set is Abner, then Benny, etc.
for f=1:length(fams)
fSet=fams(f,:);
for t=1:length(types)
tSet=types(t,:);
aType=tSet(1);
aBros=find(fSet==fSet(1));
aBros=aBros(aBros~=1);
aBrosT=tSet(aBros);
s1=isequal(aBrosT,'ll');
if s1==false && aType=='k' || s1==true && aType=='l'
continue
end
bType=tSet(2);
bBros=find(fSet==fSet(2));
bBros=bBros(bBros~=2);
bBrosT=tSet(bBros);
s2=isequal(bBrosT,'kk');
if s2==false && bType=='k' || s2==true && bType=='l'
continue
end
cType=tSet(3);
s3=isequal([tSet(1) tSet(2)],'ll');
if s3==false && cType=='k' || s3==true && cType=='l'
continue
end
dType=tSet(4);
s4=fSet(4)==fSet(3);
if s4==false && dType=='k' || s4==true && dType=='l'
continue
end
eType=tSet(5);
s5=fSet(5)==fSet(2);
if s5==false && eType=='k' || s5==true && eType=='l'
continue
end
fType=tSet(6);
s6=tSet(5)=='k';
if s6==false && fType=='k' || s6==true && fType=='l'
continue
end
s7=fSet(2)=='p';
if s7==false && fType=='k' || s7==true && fType=='l'
continue
end
disp('abcdef')
disp(fSet)
disp(tSet)
disp(' ')
end
end
finds
abcdef initials
tptppt family name initials
llklkk type
The fact that neither family had all liars was not used.
Abner Turner: liar
Benny Pearson: liar
Connor Turner: knight
Damian Pearson: liar
Eldon Pearson: knight
Freddy Turner: knight
|
Posted by Charlie
on 2022-05-01 10:22:57 |