| Here again is the text of the puzzle. |
|
| Harriet, upon returning from the mall, is happily describing her four
shoe purchases to her friend Aurora. Aurora just loves the four
different kinds of shoes that Harriet bought (ecru
espadrilles, fuchsia flats,
purple
pumps, and suede sandals),
but Harriet can't recall at which different store
(Foot Farm, Heels
in a Handcart, The Shoe Palace,
or Tootsies) she got each
pair. Can you help these two figure out the order in which Harriet
bought each pair of shoes, and where she bought each?
1. Harriet bought fuchsia flats at Heels in a Handcart. 2. The store she visited just after buying her purple pumps was not Tootsies. 3. The Foot Farm was Harriet's second stop. 4. Two stops after leaving The Shoe Place, Harriet bought her suede sandals. |
Red is raw data. Blue is a relationship. Green is meta-data (information about the data). Black text is mostly unnecessary, put there to make the puzzle entertaining. Black can generally be ignored. |
| The Introduction indicates that there are four different kinds of shoes, purchased at four different stores. | The ECLiPSe function alldifferent/1 can be applied whenever the clues indicate that each value in a list is unique. |
| The challenge is find the appropriate domain values. | |
| One alternative is to use the names of the stores and names of the
shoes as domain values.
[Shoe1, Shoe2, Shoe3, Shoe4] :: [ee, ff, pp, ss],
[Store1, Store2, Store3, Store4] :: [heels_handcart, foot_farm,
shoe_palace, tootsies],
|
The problem with this approach is that the two groups of variables have NO VALUE COMMONALITY -- variables in the 'shoes' group can't be compared to variables in the 'store names' group. |
| The Numbered Clues contain sequence information (using words like "at", "before", "second stop") which crosses over between shoes and store names. | Sequence information translates into familiar algebraic equations (equals, less than, greater than), provided the variables contain numeric values. |
| In order to use this information, we have to change the focus of the domain variable values. | |
| The clues tell us that each shoe is either 1st, 2nd, 3rd, or 4th. Similarly, each store_name is either 1st, 2nd, 3rd, or 4th. | There is VALUE COMMONALITY between the groups. |
| We revise the formulation to use the names of the stores and names
of the shoes AS VARIABLES, representing SEQUENCE.
[EE, FF, PP, SS] :: [1..4],
[Heels_handcart, Foot_farm, Shoe_palace, Tootsies] :: [1..4],
|
Note the use of starting capital letters for variables.
Be careful with the naming of variables! In this case FF is used for 'fuchsia flats', but could be misread as 'Foot Farm'. Spelling out variables is a pain, but so is debugging. In more complex puzzles it helps to include the group in the variable name. Instead of FF, use Shoe_FF, instead of PP use Shoe_PP. Foot_farms becomes Store_FF. |
| Now we can use the Numbered Clues to compare the shoes to the stores_names. | lib(fd) uses #=, ##, #<, etc., to compare values |
| 1. Harriet bought fuchsia flats at Heels in a Handcart. | FF #= Heels_handcart
(The sequence number for fuchsia flats is the same as for Heels in a Handcart) |
| 2. The store she visited just after buying her purple pumps was not Tootsies. | PP + 1 ## Tootsies
(Just after is one greater. Whatever store that is one greater than PP is not Tootsies). |
| 3. The Foot Farm was Harriet's second stop. | Foot_farm #= 2 |
| 4. Two stops after leaving The Shoe Place, Harriet bought her suede sandals. | Shoe_palace + 2 #= SS |
| When you have culled all the clues out of the information, you run it through ECLiPSe. Look at the Solution for this puzzle to see the code. Different variable names were used, but they represent the same values as stated here. The writeln stuff at the end is added solely to make it easier to read the results. |