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

Home > Logic
Who gave what to whom? (Posted on 2023-11-28) Difficulty: 2 of 5
Participants: Book, Candy, Flowers, Money and Scarf.
Gifts: book, candy, flowers, money and scarf.
The participants are unmarried, grown-up people of mixed genders, each being both a giver (donor) and a receiver, in a way that no one gave or received an item bearing his or her name and none gave a present to the person from whom he or she received one.

The present received by Flowers was the name of the donor of the scarf, Scarf sent flowers to the book-giver, Candy gave Scarf a present and Book received candy.

a. Find out, who gave what to whom.
b. You may deduce (with no certainty) from the nature of the gifts the probable gender of each of the people mentioned,

Source : (Slightly abridged) problem #98 from Penguin’s Problems book by William and Savage 1940.

See The Solution Submitted by Ady TZIDON    
Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 7
clearvars,clc
names=["book","candy","flowers","money","scarf"];
gifts=perms(names);
recipients=perms(names);
i=1;
while i <= length(gifts)
  matches=find(gifts(i,:)==names);
  if ~isempty(matches)
    gifts(i,:)=[];
  else
    i=i+1;
  end
end
recipients=gifts;
for g=1:length(gifts)
  gift=gifts(g,:);
  for r=1:length(recipients)
    recipient=recipients(r,:);
    matches=find(gift==recipient);
    if ~isempty(matches) || recipient(2)~="scarf"
      continue
    end
    if gift(find(recipient=="book"))~="candy" ...
        || gift(5)~="flowers"
      continue
    end
    bookGiver=names(find(gift=="book"));
    if bookGiver~=recipient(5)
      continue
    end
    disp(recipient)
    disp(gift)
    disp(' ')
  end
end

finds

    "flowers"    "scarf"    "book"    "candy"    "money"
    "scarf"    "money"    "candy"    "book"    "flowers"
 
    "candy"    "scarf"    "book"    "flowers"    "money"
    "scarf"    "money"    "candy"    "book"    "flowers"
 
    "flowers"   "scarf"    "money"    "book"    "candy"
    "money"    "book"    "scarf"    "candy"    "flowers"
 
Rather than add to the program, it's obvious that only the last set has Flowers being given a present that was the namesake of the scarf donor, as the sequence of donors is the top line below.

Donor:          "Book",    "Candy",  "Flowers",  "Money",   "Scarf"
recipient:      "candy"    "scarf"    "book"    "flowers"    "money"
gift:           "scarf"    "money"    "candy"    "book"    "flowers"


  Posted by Charlie on 2023-11-28 14:43:37
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 (9)
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