/////////////////////////////////////////////////////////////////////////////// // // Title: Share and Share Unalike // Author: NameHere // Publication: Dell Logic Puzzles // Issue: April, 1998 // Page: 35 // Stars: 4 // // A gang of thieves in London in the early 1800's had an unusual and complex // method of dividing their booty. The ten men (Andrew, Colin, Dandy Dan, Ethan, // Georgie, Jerry, Little Lester, Morgan, Richard, and Vic) were each ranked // and given a number, and then arranged into four tiers as shown below. // Everyone had to share what he stole with all those of a higher rank, but // not with anyone of equal or lesser rank. For example, 8 had to share with // numbers 1 through 6, while 2 only had to share with 1 -- who was leader of // the gang. (Everyone, of course, also got a share of whatever he had brought // in himself.) During one week, each member was able to contribute one item // to the gang's collection (a pair of boots, clock, bag of gold pieces, pie, // bag of shillings, silver teapot, tin of tea, top hat, umbrella, and velvet // cloak). // Can you find the rank, and booty for each man? // // // Four Ranks: First(1), Second (2,3), Third (4,5,6) // and Lowest (7,8,9,10) // // -1- // -2- -3- // -4- -5- -6- // -7- -8- -9- -10- // // // 1. The leader (who wasn't Richard) brought a shiny new black umbrella, which // he claimed to have found in the rubbish. // 2. Little Lester (whose number was odd) was in the same rank as the man who // brought a magnificent and only slightly damaged long-case clock. // 3. Although three other members were entitled to a piece of the rather moldy // steak and kidney pie that Georgie stole, they let him have it all to himself. // 4. Vic's number was exactly twice that of the man who found the top hat. // 5. Richard and Little Lester both got part of the bag of shillings as their // share, but Ethan didn't. // 6. There were exactly three members who weren't entitled to the tin of tea, // but the others felt generous and let the whole gang enjoy a cup. // 7. Seven men wasted no time in divvying up the bag of gold pieces. // 8. The gentleman's velvet cloak (upon which Andrew had no claim) was // contributed by a man with an even number. // 9. Georgie isn't member #4. // 10. Jerry's number was exactly three times Colin's, but one less than that of // the man who stole a silver teapot. // 11. The man who contributed the pair of fine leather boots was entitled to a // share of Vic's booty as well, and both were entitled to items contributed // by any of the men in the bottom rank. // 12. Neither Dandy Dan (who didn't bring the velvet cloak) nor Jerry could claim // a share of the gold pieces. // /////////////////////////////////////////////////////////////////////////////// // // query: // all ShareAndShareUnalikeBreakingNews(member,booty) // /////////////////////////////////////////////////////////////////////////////// // // result: // // member = [ {Andrew} 7, {Colin} 3, {Dandy_Dan} 10, {Ethan} 8, {Georgie} 6, // {Jerry 9, {Little_Lester} 5, {Morgan} 1, {Richard} 2, {Vic} 4] // // booty = [ {Boots} Colin, {Clock} Vic, {Gold} Andrew, {Pie} Georgie, // {Shillings} Little_Lester, {Teapot} Dandy_Dan, {Tea} Jerry, // {Hat} Richard, {Umbrella} Morgan, {Velvet_Cloak} Ethan] // /////////////////////////////////////////////////////////////////////////////// Thief = Andrew | Colin | Dandy_Dan | Ethan | Georgie | Jerry | Little_Lester | Morgan | Richard | Vic Booty = Boots | Clock | Gold | Pie | Shillings | Teapot | Tea | Hat | Umbrella | Velvet_Cloak Booties = Booty->>Thief Members = Thief->>[1..10] pred ShareAndShareUnalike(member:: Members, booty::Booties) iff // 1. The leader (who wasn't Richard) brought a shiny new black umbrella, which // he claimed to have found in the rubbish. member(Richard) <> 1 & member(booty(Umbrella)) = 1 & // 2. Little Lester (whose number was odd) was in the same rank as the man who // brought a magnificent and only slightly damaged long-case clock. member(Little_Lester) mod 2 = 1 & booty(Clock) <> Little_Lester & SameRank(member,Little_Lester,booty(Clock)) & // 3. Although three other members were entitled to a piece of the rather moldy // steak and kidney pie that Georgie stole, they let him have it all to himself. booty(Pie) = Georgie & Rank(member,Georgie,3) & // 4. Vic's number was exactly twice that of the man who found the top hat. member(Vic) = 2*member(booty(Hat)) & // 5. Richard and Little Lester both got part of the bag of shillings as their // share, but Ethan didn't. GreaterRank(member,Ethan,Richard) & GreaterRank(member,Ethan,Little_Lester) & ((booty(Shillings) = Richard & GreaterRank(member,Richard,Little_Lester)) | (booty(Shillings) = Little_Lester & GreaterRank(member,Little_Lester,Richard))) & // 6. There were exactly three members who weren't entitled to the tin of tea, // but the others felt generous and let the whole gang enjoy a cup. Rank(member,booty(Tea),4) & // 7. Seven men wasted no time in divvying up the bag of gold pieces. Rank(member,booty(Gold),4) & // 8. The gentleman's velvet cloak (upon which Andrew had no claim) was // contributed by a man with an even number. member(booty(Velvet_Cloak)) mod 2 = 0 & member(booty(Velvet_Cloak)) <> member(Andrew) & SameOrGreaterRank(member,Andrew,booty(Velvet_Cloak)) & // 9. Georgie isn't member #4. member(Georgie) <> 4 & // 10. Jerry's number was exactly three times Colin's, but one less than that of // the man who stole a silver teapot. member(Jerry) = 3*member(Colin) & member(Jerry) = member(booty(Teapot)) - 1 & // 11. The man who contributed the pair of fine leather boots was entitled to a // share of Vic's booty as well, and both were entitled to items contributed // by any of the men in the bottom rank. member(booty(Boots)) < 7 & member(Vic) < 7 & // 12. Neither Dandy Dan (who didn't bring the velvet cloak) nor Jerry could claim // a share of the gold pieces. booty(Velvet_Cloak) <> Dandy_Dan & booty(Gold) <> Dandy_Dan & booty(Gold) <> Jerry & SameOrGreaterRank(member,Dandy_Dan,booty(Gold)) & SameOrGreaterRank(member,Jerry,booty(Gold)) /////////////////////////////////////////////////////////////////////////////// // Four Ranks: First(1), Second (2,3), Third (4,5,6) // and Lowest (7,8,9,10) // // -1- // -2- -3- // -4- -5- -6- // -7- -8- -9- -10- // local pred Rank(member::Members, x::Thief, rank:<I[1..4]) iff (rank = 1 & member(x) = 1) | (rank = 2 & member(x) >= 2 & member(x) <= 3) | (rank = 3 & member(x) >= 4 & member(x) <= 6) | (rank = 4 & member(x) >= 7 {& member(x) <= 10}) local pred SameRank(member::Members, x1::Thief, x2::Thief) iff (Rank(member,x1,1) & Rank(member,x2,1)) | (Rank(member,x1,2) & Rank(member,x2,2)) | (Rank(member,x1,3) & Rank(member,x2,3)) | (Rank(member,x1,4) & Rank(member,x2,4)) local pred GreaterRank(member::Members, x1::Thief, x2::Thief) iff (Rank(member,x1,2) & Rank(member,x2,1)) | (Rank(member,x1,3) & Rank(member,x2,1)) | (Rank(member,x1,3) & Rank(member,x2,2)) | (Rank(member,x1,4) & Rank(member,x2,1)) | (Rank(member,x1,4) & Rank(member,x2,2)) | (Rank(member,x1,4) & Rank(member,x2,3)) local pred SameOrGreaterRank(member::Members, x1::Thief, x2::Thief) iff SameRank(member,x1,x2) | GreaterRank(member,x1,x2)
This page was created by F1toHTML