In J K Rowling's Harry Potter and the Philosopher's Stone (if you're American and have been deprived of the chance for this book to enrich your knowledge of alchemy to the fullest extent possible, go and look it up), Harry and his friend Hermione find themselves trapped in a room containing seven potion bottles of different sizes, standing in a row, and a piece of parchment on which a riddle is written. Black fire guards the way forward and purple fire the way back. The parchment tells them that two of the bottles contain potions which will help them get through the flames. Of the other five bottles, two contain harmless nettle wine, while the other three hold poison. They are given four clues to work out which is which.
My first reaction on reading this was to cover up the bottom of the page, where Hermione tells Harry the answer, and try to work it out myself. To paraphrase, here are the clues:
Unfortunately, the third clue is useless because we are not told (though Hermione can see) where the largest and smallest bottles are.
So what can we work out? For convenience, imagine that the potions are numbered 1 to 7 from left to right. I will also refer to the two useful potions as "forwards potion" and "backwards potion".
From this basic application of the clues, there are still multiple possibilities for all the bottles:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
|---|---|---|---|---|---|---|---|
| Forwards potion | No | No | Maybe | Maybe | Maybe | No | No |
| Backwards potion | Maybe | No | Maybe | Maybe | Maybe | No | Maybe |
| Poison | Maybe | Maybe | Maybe | Maybe | Maybe | Maybe | Maybe |
| Nettle wine | No | Maybe | Maybe | Maybe | Maybe | Maybe | Maybe |
Not very promising. However, if we start guessing, we can work out some more:
Suppose 2 and 6 are poison. If 3 is nettle wine, 4 cannot be, since 3 would then have to be poison instead. So the second wine bottle is either 5 or 7. However, it can't be 5, because that would mean 4 was poison and either 1 or 7 was forwards potion, which is not allowed.
If 3 is not nettle wine, then 7 is, and the other one is 4 or 5. This puts the third bottle of poison at 3 or 4, which means 1 is backwards potion (the only possible thing left). The forwards potion is at either 3 or 5.
We now have only 8 possibilities:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|
| Backwards potion | Poison | Nettle wine | Forwards potion | Poison | Poison | Nettle wine |
| Poison | Poison | Nettle wine | Backwards potion | Forwards potion | Poison | Nettle wine |
| Poison | Poison | Nettle wine | Forwards potion | Backwards potion | Poison | Nettle wine |
| Backwards potion | Poison | Nettle wine | Poison | Forwards potion | Poison | Nettle wine |
| Backwards potion | Poison | Poison | Nettle wine | Forwards potion | Poison | Nettle wine |
| Backwards potion | Poison | Forwards potion | Poison | Nettle wine | Poison | Nettle wine |
| Poison | Nettle wine | Forwards potion | Poison | Poison | Nettle wine | Backwards potion |
| Poison | Nettle wine | Poison | Forwards potion | Poison | Nettle wine | Backwards potion |
There is, however, a fifth clue. We are told that Hermione can work out where the two useful potions are. What does this tell us about where the smallest and largest bottles are? The smallest and largest bottles cannot contain poison. So if we know where they are, as Hermione does, we can eliminate all the options with poison in those positions. The following table shows the number of options left for each pair of positions of the smallest and largest bottles (it doesn't matter which is which):
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
|---|---|---|---|---|---|---|---|
| 7 | 4 | 2 | 6 | 5 | 5 | 2 | |
| 6 | 0 | 2 | 1 | 1 | 0 | ||
| 5 | 3 | 0 | 4 | 3 | |||
| 4 | 2 | 1 | 3 | ||||
| 3 | 3 | 1 | |||||
| 2 | 0 |
Looking for the cells with 1 in, for Hermione to solve the puzzle either the smallest or largest bottle must be in place 2 or 6, and the other one must be in place 3 or 4. This could end up as either of the last two rows in the previous table. So the answer is that the backwards potion is on the right (place 7) and the forwards potion is in either place 3 or 4, whichever one is the extra large or small bottle. This agrees with Hermione's answer (but we can't tell even from her answer whether the forwards potion was in place 3 or 4).