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

Home > Logic
Logic of pets (Posted on 2023-08-21) Difficulty: 3 of 5
Robert and Andrew are two men, and Mary and Jessica are two women. Their last names are Jones, Smith, Coleman, and Thompson. One of them has a dog, one has a cat, one has a bird, and one has a rabbit. The pets are named Goody, Lovey, Lucky, and Weirdo.

1. Robert's pet's name starts with L.
2. Jessica Coleman has a cat, but it is not named Weirdo.
3. Mary does not have a dog because she hates dogs.
4. Lucky is a rabbit.
5. Mr. Jones has a bird.
6. Mary's last name is not Thompson.
7. Weirdo's last name is not Jones.

What is the first name and last name of each person? What pet does each person have? What is the name of each pet?

No Solution Yet Submitted by Math Man    
Rating: 4.5000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution (spoiler) | Comment 1 of 5
people='ramj';
robert=1;
andrew=2;
mary=3;
jessica=4;
surnames='jsct';
pets='dcbr';
petnames='glLw';
surnames=perms(surnames);
pets=perms(pets);
petnames=perms(petnames);

for i=1:length(surnames)
  surname=surnames(i,:);
  for j=1:length(pets)
    pet=pets(j,:);
    for k=1:length(petnames)
      petname=petnames(k,:);
      good=true;
      if lower(petname(robert))~='l'
        good=false;
        continue
      end
      if pet(jessica)~='c' ...
          || petname(jessica)=='w' ...
          || surname(jessica)~='c'
        good=false;
        continue
      end
      if pet(mary)=='d'
        good=false;
        continue
      end
      lucky=strfind(petname,'L');
      if pet(lucky)~='r'
        good=false;
        continue
      end
      jones=strfind(surname,'j');
      if pet(jones)~='b' || jones > 2
        good=false;
        continue
      end
      if surname(mary)=='t'
        good=false;
        continue
      end
      weirdo=strfind(petname,'w');
      if surname(weirdo)=='j'
        good=false;
        continue
      end
      disp(people)
      disp(surname)
      disp(pet)
      disp(petname)
      disp(' ')
    end
  end
end

finds

>> logicOfPets
ramj
jtsc
bdrc
lwLg
 
Robert Jones has a bird named Lovey.
Andrew Thompson has a dog named Weirdo.
Mary Smith has a rabbit named Lucky.
Jessica Coleman has a cat named Goofy.


  Posted by Charlie on 2023-08-21 11:03:56
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 (0)
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