HomeHome More SamplesMore Samples
///////////////////////////////////////////////////////////////////////////////
//
// Title: Wired Up
// Author: NameHere
// Publication: Dell Logic Puzzles
// Issue: April, 1998
// Page: 23
// Stars: 3
// 
// Six young adults just out of college share a four-bedroom apartment. They 
// include two women (Dana and Geneva) and four men (Clark, Justin, Sam, and 
// Tyler). Though quarters are tight, they get along well -- except for the 
// never-ending issue of the cable television. Only the set in the den is wired 
// to get cable, and each person has a different favorite channel (business, 
// cartoons, comedy, movies, nostalgia, and sports) with a different number 
// (40, 35, 30, 25, 20, and 15), so there's a constant battling to see who 
// gets to watch what. 
// 
// Can you find each roommate's full name (last names are Beres, Engel, Kolb, 
// Martinez, Nass, and Wahl) and favorite channel -- by both subject and number?
// 
// 1. The two women share one of the four bedrooms, while Justin and the 
//    cartoon aficionado share another.
// 2. Tyler's favorite channel has a number ten less than the nostalgia channel,
//    but ten more than Ms. Nass's favorite.
// 3. The movie channel is the favorite of one of the men, but not Mr. Kolb.
// 4. Sam's favorite channel has a number ten more than Wahl's, but five less 
//    than the sports channel.
// 5. Mr. Engel shares a room, but the lover of the comedy channel doesn't. 
// 6. Beres's favorite channel has a number five more than Clark's, but five 
//    less than Geneva's.
// 7. The number of Justin's favorite channel isn't 40.
// 8. Tyler hates cartoons.
// 
// Determine: First name -- Last name -- Channel -- Number
//
///////////////////////////////////////////////////////////////////////////////
//
// Query: 
//          all WiredUp(channel,name,number) 
//
///////////////////////////////////////////////////////////////////////////////
//
// Result:
//
// channel = [ {Dana} Business, {Geneva} Sports, {Clark} Cartoons, 
//             {Justin} Movies, {Sam} Nostalgia, {Tyler} Comedy]
//
// name =    [ {Beres} Sam, {Engel} Justin, {Kolb} Clark, {Martinez} Geneva, 
//             {Nass} Dana, {Wahl} Tyler]
//
// number =  [ {Business} 15, {Cartoons} 30, {Comedy} 25, {Movies} 20, 
//             {Nostalgia} 35, {Sports} 40]   
//
///////////////////////////////////////////////////////////////////////////////
//
// Notes: 
//      The titles "Mr." and "Ms." serve to determine gender.
//
///////////////////////////////////////////////////////////////////////////////

FirstName = Dana | Geneva | Clark | Justin | Sam | Tyler
LastName = Beres | Engel | Kolb | Martinez | Nass | Wahl 
Channel = Business | Cartoons | Comedy | Movies | Nostalgia | Sports

Channels = FirstName->>Channel
Names = LastName->>FirstName
Number = Channel->>[15..40]

pred WiredUp(channel::Channels,name::Names,number::Number) iff
    shares::rel FirstName &
    number(_) = 40 &
    number(_) = 35 &
    number(_) = 30 &
    number(_) = 25 &
    number(_) = 20 &
    number(_) = 15 &

// 1. The two women share one of the four bedrooms, while Justin and the 
//    cartoon aficionado share another.
    Dana in shares & Geneva in shares &
    channel(cartoon_aficionado) = Cartoons &
    Justin <> cartoon_aficionado &
    Justin in shares & cartoon_aficionado in shares &
    Dana <> cartoon_aficionado &
    Geneva <> cartoon_aficionado &

// 2. Tyler's favorite channel has a number ten less than the nostalgia channel,
//    but ten more than Ms. Nass's favorite.
    number(channel(Tyler)) = number(Nostalgia) - 10 &
    name(Nass) <> Tyler & IsWoman(name(Nass)) &
    number(channel(Tyler)) = number(channel(name(Nass))) + 10 & 

// 3. The movie channel is the favorite of one of the men, but not Mr. Kolb.
    channel(x) = Movies & IsMan(x) &
    IsMan(name(Kolb)) & channel(name(Kolb)) <> Movies &  

// 4. Sam's favorite channel has a number ten more than Wahl's, but five less 
//    than the sports channel.
    number(channel(Sam)) = number(channel(name(Wahl))) + 10 &
    number(channel(Sam)) = number(Sports) - 5 &

// 5. Mr. Engel shares a room, but the lover of the comedy channel doesn't. 
    IsMan(name(Engel)) &
    channel(name(Engel)) <> Comedy &
    channel(comedy_lover) = Comedy &
    ~comedy_lover in shares &

// 6. Beres's favorite channel has a number five more than Clark's, but five 
//    less than Geneva's.
    number(channel(name(Beres))) = number(channel(Clark)) + 5 &
    number(channel(name(Beres))) = number(channel(Geneva)) - 5 &  

// 7. The number of Justin's favorite channel isn't 40.
    number(channel(Justin)) <> 40 &

// 8. Tyler hates cartoons.
    channel(Tyler) <> Cartoons

local pred IsWoman(name::FirstName) iff
    name = Dana | name = Geneva

local pred IsMan(name::FirstName) iff
    name =  Clark | name = Justin | name = Sam | name = Tyler




This page was created by F1toHTML