HomeHome More SamplesMore Samples
///////////////////////////////////////////////////////////////////////////////
//
// Title: Ticket Sellers
// Author: Diane Yoko
// Publication: Dell Logic Puzzles
// Issue: June, 1998
// Page: 18
// Stars: 3
// 
// Six of the ticket sellers for a local fair's raffle all live in the same 
// building. Each of the three men (Jeff, Morris, and Stewart) and three women 
// (Abigail, Delia, and Lucy) live on a different one of the building's six 
// floors. Can you find out the full name of each floor's tenant (last names are 
// Banner, Carson, Dixon, Herd, Jones, and Miller), and how many tickets each 
// one sold? 
// 
//  1. In all, the six sold 280 tickets; each sold at least one. 
//  2. Stewart lives one floor below Jones. 
//  3. Delia isn't Herd or Dixon. 
//  4. Lucy lives on a higher floor than Abigail, but a lower floor than Herd. 
//  5. Morris lives one floor above Miller, and one floor below the man who sold 
//     40 tickets. 
//  6. Banner doesn't live on the first or sixth floor. 
//  7. Jeff sold half as many tickets as did the sixth-floor tenant, who sold 
//     half as many as Carson. 
//  8. Abigail doesn't live on the first floor. 
//  9. Morris sold 20 more tickets than Carson (who isn't Abigail). 
// 10. Miller sold 10 fewer tickets than Banner. 
// 
///////////////////////////////////////////////////////////////////////////////
//
// Query: 
//          all TicketSellers(tickets,floor,name)  
//
///////////////////////////////////////////////////////////////////////////////
//
// Result:
//
// tickets = [ {Banner} 80, {Carson} 40, {Dixon} 10, {Herd} 60, {Jones} 20, 
//             {Miller} 70]
//
// floor   = [ {Banner} 2, {Carson} 5, {Dixon} 1, {Herd} 4, {Jones} 6, 
//             {Miller} 3]
//
// name    = [ {Jeff} Dixon, {Morris} Herd, {Stewart} Carson, {Abigail} Banner, 
//             {Delia} Jones, {Lucy} Miller]
//
///////////////////////////////////////////////////////////////////////////////
//
// Notes: 
//
//  (1) The type "Tickets" guarantees at least one ticket per person.
//      If we use long integers ("L"), we don't need to specify the upper
//      range of tickets. If using "I", a safe bet for the upper range would be
//      280 (see the clue 1)  
//  (2) Note we prefer to multiply over divide (2 times instead of 1/2)
//  (3) Note the clue 5 says "man"
//
///////////////////////////////////////////////////////////////////////////////

FirstName = Jeff | Morris | Stewart | Abigail | Delia | Lucy
LastName = Banner | Carson | Dixon | Herd | Jones | Miller

Tickets = LastName->L[1..]      // at least one ticket each, no upper range
Floors = LastName->>I[1..6]
Names = FirstName->>LastName

pred TicketSellers(tickets::Tickets,floor::Floors,name::Names) iff
//  1. In all, the six sold 280 tickets; each sold at least one. 
    tickets(Banner) + tickets(Carson) + tickets(Dixon) + tickets(Herd) +
    tickets(Jones) + tickets(Miller) = 280 &

//  2. Stewart lives one floor below Jones. 
    floor(name(Stewart)) = floor(Jones) - 1 &

//  3. Delia isn't Herd or Dixon. 
    name(Delia) <> Herd & name(Delia) <> Dixon &

//  4. Lucy lives on a higher floor than Abigail, but a lower floor than Herd. 
    floor(name(Lucy)) > floor(name(Abigail)) &
    floor(name(Lucy)) < floor(Herd) &

//  5. Morris lives one floor above Miller, and one floor below the man who sold 
//     40 tickets. 
    floor(name(Morris)) = floor(Miller) + 1 &
    tickets(man) = 40 & (man = name(Jeff) | man = name(Morris) | man = name(Stewart)) &
    floor(name(Morris)) = floor(man) - 1 &

//  6. Banner doesn't live on the first or sixth floor. 
    floor(Banner) <> 1 & floor(Banner) <> 6 &

//  7. Jeff sold half as many tickets as did the sixth-floor tenant, who sold 
//     half as many as Carson. 
    floor(sixth_floor_tenant) = 6 &
    2*tickets(name(Jeff)) = tickets(sixth_floor_tenant) &
    2*tickets(sixth_floor_tenant) = tickets(Carson) &

//  8. Abigail doesn't live on the first floor. 
    floor(name(Abigail)) <> 1 &

//  9. Morris sold 20 more tickets than Carson (who isn't Abigail). 
    tickets(name(Morris)) = tickets(Carson) + 20 &
    name(Abigail) <> Carson &

// 10. Miller sold 10 fewer tickets than Banner. 
    tickets(Miller) = tickets(Banner) - 10




This page was created by F1toHTML