Thursday, February 4, 2010

The "Harry Potter" Bottle Puzzle.

In the first "Harry Potter" book there is a logic puzzle toward the end of the book. They are trying to get safely through a door in front of them (Forward) or they can give up and go Backwards through the door behind them. The doors are closed by fire until they choose and drink from one of the 7 bottles in a line on a table in front of them. Also on the table is a parchment with the following written statements:
Danger lies before you, while safety lies behind,
Two of us will help you, whichever you would find,
One among us seven will let you move ahead,
Another will transport the drinker back instead,
Two among our number hold only nettle wine,
Three of us are killers, waiting hidden in line.
Choose, unless you wish to stay here forevermore,
To help you in your choice, we give you these clues four:
First, however slyly the poison tries to hide
You will always find some on nettle wine’s left side;
Second, different are those who stand at either end,
But if you would move onward, neither is your friend;
Third, as you see clearly, all are different size,
Neither dwarf nor giant holds death in their insides;
Fourth, the second left and the second on the right
Are twins once you taste them, though different at first sight.
So one bottle is forward F, one is backwards B, two are nettle wine W, and three are Poison P. They are all different sizes and the sight of the liquid doesn't mean they're different.

I start with the fourth clue that positions 2 and 6 are the same. Forward and Backward have no twins so 2 and 6 must be either Wine or Poison. If wine then 1 and 5 are Poison by the first clue that to the left of Wine will always be Poison. This yields two possibilities.

Possibility "A" : P W # # P W #
Possibility "B" : # P # # # P #

Next, further develop possibility "A". By the second clue the two ends are different and neither is Forward, therefore position 7 is not Poison like position 1, and is not Forward. The only thing left is for position 7 to be is Backwards.

Possibility "A" : P W # # P W B

The two positions left are either Forward and Poison or Poison and Forward, yielding two possibilities.

Possibility "A1" : P W F P P W B
Possibility "A2" : P W P F P W B

Now back to possibility "B". By the second clue neither end is Forward leaving Forward to be in Position 3, 4, or 5.

Possibility "B1" : # P F # # P #
Possibility "B2" : # P # F # P #
Possibility "B3" : # P # # F P #

Now we fill in the remaining three positions of each possibility. The first clue says that Wine will always have a Poison to it's left. Position 1 has no left, therefore it cannot be a Wine. I start with finding which two of the three remaining positions are Wine.

Possibility "B1", Wine can't be in position 4 since that requires 3 to not be Forward. The two Wines fill positions 5 and 7. Position 4 must be a Poison to the left of Wine, leaving position 1 to be Backward.

Possibility "B1" : B P F P W P W

Possibility "B2", Wine can't be in position 5 since that requires 4 to not be Forward. The two Wines fill positions 3 and 7. Positions 1 and 5 can be either Backward or Poison, yielding two more possibilities.

Possibility "B2a" : B P W F P P W
Possibility "B2b" : P P W F B P W

Possibility "B3", Wine can't be in both position 3 and 4 because that would require 3 to be Poison (to the left of 4). If position 1 can't be Wine and only one Wine can fit in 3 and 4, then position 7 is the only place where the second Wine can fit. The first Wine can be in either 3 or 4, yielding two further possibilities.

Possibility "B3a" : # P # W F P W
Possibility "B3b" : # P W # F P W

Further developing possibility "B3a", the first Wine must have a Poison to the left, leaving position 1 to be Backwards.

Possibility "B3a" : B P P W F P W

Further developing possibility "B3b", positions 1 and 3 are either Backwards and Poison or Poison and Backwards respectively, yielding two further possibilities.

Possibility "B3b1" : B P W P F P W
Possibility "B3b2" : P P W B F P W

This ends us with eight possibilities. Which position/bottle is the smallest and which is the largest (neither dwarf nor giant) is not stated in the book (though the characters could obviously see this). I don't believe it can be further reduced without knowing which positions are the Smallest and Largest bottles.

Possibility "A1" : P W F P P W B
Possibility "A2" : P W P F P W B
Possibility "B1" : B P F P W P W
Possibility "B2a" : B P W F P P W
Possibility "B2b" : P P W F B P W
Possibility "B3a" : B P P W F P W
Possibility "B3b1" : B P W P F P W
Possibility "B3b2" : P P W B F P W

The question now comes: "Can the puzzle be solved if we knew the missing information that the characters of the book would have had?"

It is revealed in the book that the Smallest bottle turns out to be the way Forward, and that the bottle in position 7 is Backward. The reveal that 7 is Backward indicates it is an "A" possibility. However, these are reveals and not clues or data known to the characters.

Neither dwarf nor giant holds death. It doesn't seem to matter which is which, so here goes.

Either the Smallest or Largest (s/l) is in one of the seven positions and the other is in one of the remaining six positions. This yields 42 possibilities of where they are. If s/l is in position 2 or 6 then the other s/l cannot be in 1 or 5. If s/l is in either 1 or 5 then the other cannot be in 1 or 6. This eliminates 8 possibilities leaving 34 variations.

If either 2 or 6 are either Smallest or Largest (s/l) then it must be a Possibility "A", and if either 3 or 4 is s/l then the puzzle is solved. So if the book situation is any of these 4 variations then we and the characters could solve the puzzle and the solution would be either A1 or A2.

Do any of the other 30 variations of s/l positions solve the puzzle?

If s/l are in both positions 1 and 7 then the puzzle can NOT be solved. If s/l are in both positions 2 and 6 then the puzzle can NOT be solved. This eliminates four more variations since the characters DO solve the puzzle.

Do any of the other 26 variations of s/l positions solve the puzzle?

I'll leave it at that for now since my brain is going dead.

No comments: