Home More Samples
```///////////////////////////////////////////////////////////////////////////////
//
// Title: Blueberry Muffins
// Author: Charles Morse
// Publication: Dell Logic Puzzles
// Issue: April, 1998
// Page: 11
// Stars: 2
//
// Daniel made a dozen blueberry muffins on Friday night -- and by the time he
// was ready for brunch on Saturday, there were only two left. The other ten
// had been snitched by his housemates, all of whom had gotten up early because
// they had to work on Saturday. The four housemates include two men named Bill
// and Mark, and two women named Calla and Lynn; last names are Ellis, Ingham,
// Oakley, and Summers, and their differing professions are dogcatcher,
// flautist, secretary, and zookeeper.
// Can you discover each one's full name, profession, and number of muffins
// snitched?
//
// 1. Each housemate snitched a different number of muffins from one to four.
// 2. Bill and Ellis snitched a total of six muffins.
// 3. The secretary (who is a woman) snitched more than the dogcatcher.
// 4. Mark snitched two more than Summers did.
// 5. The flautist snitched twice as many as Ms. Oakley did.
// 6. Calla's last name isn't Ingham.
//
///////////////////////////////////////////////////////////////////////////////
//
// query:
//          all BlueberryMuffins(snitched,surname,profession)
//
///////////////////////////////////////////////////////////////////////////////
//
// result:
//
// snitched   = [ {Bill} 2, {Mark} 4, {Calla} 1, {Lynn} 3]
// surname    = [ {Ellis} Mark, {Ingham} Lynn, {Oakley} Calla, {Summers} Bill]
// profession = [ {Dogcatcher} Calla, {Flautist} Bill, {Secretary} Lynn,
//                {Zookeeper} Mark]
//
///////////////////////////////////////////////////////////////////////////////

Housemate = Bill | Mark | Calla | Lynn
Lastname = Ellis | Ingham | Oakley | Summers
Profession = Dogcatcher | Flautist | Secretary | Zookeeper

Snitched = Housemate->>[1..4]       {Clue 1: different number from one to four}
Name = Lastname->>Housemate
Professions = Profession->>Housemate

pred BlueberryMuffins(snitched::Snitched,surname::Name,profession::Professions) iff
// 2. Bill and Ellis snitched a total of six muffins.
snitched(Bill) + snitched(surname(Ellis)) = 6 &

// 3. The secretary (who is a woman) snitched more than the dogcatcher.
snitched(profession(Secretary)) > snitched(profession(Dogcatcher)) &
(profession(Secretary) = Calla | profession(Secretary) = Lynn) &

// 4. Mark snitched two more than Summers did.
snitched(Mark) = snitched(surname(Summers)) + 2 &

// 5. The flautist snitched twice as many as Ms. Oakley did.
snitched(profession(Flautist)) = 2*snitched(surname(Oakley)) &

// 6. Calla's last name isn't Ingham.
surname(Ingham) <> Calla

```