Xmas
The Filenes Christmas Shopping Puzzle
12 couples were waited on consecutively, as they bought a total of 8 each
of the following items:
- Aris Gloves
- Airplane Book
- COCO Perfume
- Pearl Strands
- A Football Sweater
- A Handbag
Each husband and wife were waited on together. Each couple bought 4
items. No two couples bought the same combination of items, and none of the
couples bought two or more of the same item.
Using the following clues, can you find:
- The full name of each husband and wife.
- What order they were waited on.
- What items each couple bought.
Hint: One husband is Bob, one wife is Elizabeth, and one surname is
Stanton.
- The Craigs, who bought a handbag, were waited on before the Murphys,
who were not waited on last.
- The Collins bought Aris gloves, a sweater, and handbag, and COCO.
- The couples waited on 8th and 10th bought the Airplane Book.
- These five couples were waited on consecutively: the Smiths; Gary and
his wife; a couple who bought the Airplane Book and a handbag; the
Swains; and Bill and his wife.
- Geraldine and her husband did not buy either a handbag or a
sweater.
- The couple who were waited on last did not buy pearls.
- One of the items Tom and his wife bought was the Airplane Book.
- The Marshalls did not buy COCO or pearls.
- Evelyn and her husband bought Aris gloves but not COCO.
- These five couples were waited on consecutively: Martha and her
husband; Jack and his wife; the couple who bought Aris gloves, COCO, the
Airplane Book, and a handbag; the couple who did not buy either pearls or
the Airplane Book; and Margaret and her husband.
- The first five couples waited on all bought COCO.
- Chuck and his wife did not buy Aris gloves.
- The couples waited on first, second, and fourth did not buy a
sweater.
- Eleanor and her husband did not buy COCO.
- Neither Allen and his wife, who did not buy a handbag, nor the Anthonys
bought Aris gloves.
- Cheryl and her husband, who were not waited on 10th or 12th, and John
and his wife are two couples who bought both a sweater and a handbag.
- The Douglases, who did not buy Aris gloves or a sweater, were waited on
9th.
- Adam and his wife, who did not buy a handbag, were waited on
immediately before the Days.
- Steve and his wife bought pearls, the Airplane Book, a sweater, and one
other item.
- The last three couples waited on did not buy Aris gloves.
- The Joneses did not buy a sweater.
- Susan and her husband bought pearls.
- George and his wife bought a sweater.
- The four couples who did not buy Aris gloves are (in no particular
order): Dorothy and her husband; the Craigs; Joe and his wife; and
Rosalyn and her husband (who did not buy a sweater).
- The O'Connors bought both COCO and a sweater.
- Sandra and her husband, who did not buy a sweater, were waited on
immediately before Cathleen and her husband.
This is the apogee of the Zebra puzzle style, so pervasive in Prolog
discussions because it is well suited to the backtracking approach. All
puzzles of this style can be approached in the same way:
- Let there be a an attribute template called, for want of a better name,
the feasible functor (ff).
- For each attribute write a list of partially instantiated ffs for each
attribute value and it's related values.
- Unify the first list with some permutation of each of the others.
That deals well with positive contraints but negative constraints
(filters) have to be introduced separately.
Furthermore, it may be critical in Prolog to process constraints in a
particular (but unknown) order. That problem is neatly solved by co-routines,
but not many Prologs have that. Failing that, a terrible solution is to embed
the whole body in a permutation routine and let it thrash until a suitable
goal order is found!