All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Logic
Pizza Topping Treat (Posted on 2022-06-19) Difficulty: 3 of 5
Five ladies: Anna, Brenda, Clara, Daniella, and Elena had a pizza dinner at a restaurant.

It is known that:
  1. Each of them had three of the following toppings: sausage, pepperoni, mushroom, olives, and green pepper.
  2. The only topping that Clara and Elena had in common was sausage.
  3. The only topping Anna and Brenda had in common was pepperoni.
  4. The only topping Daniella and Elena had in common was mushroom.
  5. 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.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 4
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
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information