Home More Samples
```///////////////////////////////////////////////////////////////////////////////
//
// Title: A Round of Golf
// Author: Ellen K. Rodehorst
// Publication: Dell Favorite Logic Problems
// Issue: Summer, 2000
// Puzzle #: 9
// Stars: 1
//
// When the Sunny Hills Country Club golf course isn't in use by club members,
// of course, it's open to the club's employees. Recently, Jack and three
// other workers at the golf course got together on their day off to play
// a round of eighteen holes of golf. Afterward, all four, including Mr. Green,
// went to the clubhouse to total their scorecards. Each man works at a different
// job (one is a short-order cook), and each shot a different score in the game.
// No one scored below 70 or above 85 strokes.
// From the clues below, can you discover each man's full name, job and golf
// score?
//
// 1. Bill, who is not the maintenance man, plays golf often and had the lowest
//    score of the foursome.
// 2. Mr. Clubb, who isn't Paul, hit several balls into the woods and scored
//    ten strokes more than the pro-shop clerk.
// 3. In some order, Frank and the caddy scored four and seven more strokes
//    than Mr. Sands.
// 4. Mr. Carter thought his score of 78 was one of his better games, even
//    though Frank's score was lower.
// 5. None of the four scored exactly 81 strokes.
//
///////////////////////////////////////////////////////////////////////////////
//
// query:
//          all RoundOfGolf(lastname,job,score)
//
///////////////////////////////////////////////////////////////////////////////
//
// result:
//
// lastname = [ {Green} Frank, {Clubb} Jack, {Sands} Bill, {Carter} Paul]
// job      = [ {Cook} Bill, {Maintanance} Jack, {Clerk} Frank, {Caddy} Paul]
// score    = [ {Jack} 85, {Bill} 71, {Frank} 75, {Paul} 78]
//
///////////////////////////////////////////////////////////////////////////////
local Name = Jack | Bill | Frank | Paul
local Surname = Green | Clubb | Sands | Carter
local Jobs = Cook | Maintanance | Clerk | Caddy

local Job = Jobs->>Name
local Score = Name->>I[70..85]
local Lastname = Surname->>Name

pred RoundOfGolf(name::Lastname,job::Job,score::Score) iff
{1} job(Maintanance) <> Bill &
score(Bill) < score(Jack) & score(Bill) < score(Paul) & score(Bill) < score(Frank) &
{2} name(Clubb) <> Paul & score(name(Clubb)) = score(job(Clerk)) + 10 &
{3} score_Sands = score(name(Sands)) &
(
(score(Frank) = score(name(Sands)) + 4 & score(job(Caddy)) = score(name(Sands)) + 7) |
(score(Frank) = score(name(Sands)) + 7 & score(job(Caddy)) = score(name(Sands)) + 4)
) &
{4} score(name(Carter)) = 78 & score(Frank) < 78 &
{5} ~81 in score

```