Five ladies: Anna, Brenda, Clara, Daniella, and Elena had a pizza dinner at a restaurant.
It is known that:
- Each of them had three of the following toppings: sausage, pepperoni, mushroom, olives, and green pepper.
- The only topping that Clara and Elena had in common was sausage.
- The only topping Anna and Brenda had in common was pepperoni.
- The only topping Daniella and Elena had in common was mushroom.
- The only topping Anna and Daniella had in common was green pepper.
From the clues mentioned above, identify the toppings each of the five ladies had on their pizzas.
clearvars,clc
name=["Anna","Brenda","Clara","Daniella","Elena"];
toppings='spmog';
combos=nchoosek(toppings,3);
for a=1:10
ac=combos(a,:);
for b=1:10
bc=combos(b,:);
for c=1:10
cc=combos(c,:);
for d=1:10
dc=combos(d,:);
for e=1:10
ec=combos(e,:);
if intersect(cc,ec)=='s'
if intersect(ac,bc)=='p'
if intersect(dc,ec)=='m'
if intersect(ac,dc)=='g'
ac=string(ac); bc=string(bc);cc=string(cc);
dc=string(dc);ec=string(ec);
subscr=0;
for t=[ac bc cc dc ec]
st=char(t);
subscr=subscr+1;
fprintf('%10s:',name(subscr))
for i=1:3
switch st(i)
case 's'
fprintf(' %s',"sausage")
case 'p'
fprintf(' %s',"pepperoni")
case 'm'
fprintf(' %s',"mushroom")
case 'o'
fprintf(' %s',"olives")
case 'g'
fprintf(' %s',"green pepper")
end
if i~=3
fprintf(',')
end
end
fprintf('\n')
end
end
end
end
end
end
end
end
end
end
finds
Anna: sausage, pepperoni, green pepper
Brenda: pepperoni, mushroom, olives
Clara: sausage, olives, green pepper
Daniella: mushroom, olives, green pepper
Elena: sausage, pepperoni, mushroom
|
Posted by Charlie
on 2022-06-19 09:44:19 |