A “knowledge puzzle” in Harry Potter

In the first Harry Potter book, our heroes have to find two useful potions hidden in a collection of seven bottles. The clues are given in the book, but one of the clues refers to the biggest and smallest bottles, and the reader doesn’t know which those are. Hermione (who can see which bottle is the biggest and which the smallest) solves the puzzle.

My youngest wondered:

  • Are the clues consistent with Hermione being able to solve the puzzle?
  • Can we, the readers of the book, also solve the puzzle, given that we know that Hermione could?

These are good questions, so we worked on them together.

The puzzle

The seven bottles are in a row, and we the readers (and the characters in the book) are told:

  • (0) In some order, the bottles are: one “forward” potion, one “backward” potion, two bottles of nettle wine, and three bottles of poison. (The characters need to find the “forward” and “backward” potions to progress in their quest.)
  • (1) To the left of each bottle of wine is a bottle of poison.
  • (2) The leftmost and rightmost bottles contain liquids of different kinds; neither the leftmost nor the rightmost is the “forward” potion.
  • (3) The smallest bottle does not contain poison; neither does the largest.
  • (4) The second-from-left and second-from-right bottles are “twins” — they contain the same kind of liquid.

It’s clue (3) that makes this interesting. The characters can see which are the two special-size bottles, but we, the readers, cannot. We do know, however, that Hermione is able to solve the puzzle.

Trying to solve it

We can start by seeing how far we get without that clue. Numbering the bottles from 0 to 6, clue (4) (“twins”) tells us only these two situations are possible:

and

because wine and poison are the only things there are at least two of. We can explore these options one at a time:

Twins are wine

Starting from ?W???W?, clue (2) tells us we must have PW??PW?. We now have to find where the “forward” potion, the “backward” potion, and the last poison go. Clue (3) tells us the right-most bottle can’t be the same as the left-most (i.e., can’t be poison) and can’t be “forward”, so we must have PW??PWB.

Both of the two choices for the “forward” potion and the last poison are consistent with the clues, so we have these two possible solutions:

and

Twins are poison

On the other hand, suppose the “twins” are poison. There are different ways we could explore from here, but one way is to ask “where is the third poison?”. It can be in positions 0, 2, 3, 4, 6. Trying each:

Position 0: PP???P?

Clue (1) tells us we must have PPW??PW; and both ways of placing the “forward” and the “backward” are possible, so we get these possible solutions:

and

Position 2: ?PP??P?

We must place the wines as ?PPW?PW; then clue (2) forces one solution:

Position 3: ?P?P?P?

Two of the three poisons must have wine to the right. If we try ?PWPWP?, then “forward” must be either first or last, contradicting clue (2). The other two choices for which poisons have wine to the right give these solutions:

and

Position 4: ?P??PP?

Then to satisfy clue (1), we must place the wines as ?PW?PPW; clue (2) then forces one solution:

Position 6: ?P???PP

We cannot place both wines to satisfy clue (1), so this case is not possible.

Possible solutions without the “biggest/smallest” clue

Summarising what we’ve learnt: the following eight arrangements are the ones consistent with all clues apart from perhaps clue (3). We also show the positions of the poisons, and mark (∗) two particular solutions which are the same as far as the positions of the “forward” and “backward” potions are concerned:

  • PWPFPWB — 0 2 4
  • PWFPPWB — 0 3 4
  • PPWFBPW — 0 1 5
  • PPWBFPW — 0 1 5
  • BPPWFPW — 1 2 5 (∗)
  • BPFPWPW — 1 3 5
  • BPWPFPW — 1 3 5 (∗)
  • BPWFPPW — 1 4 5

Bringing in the “biggest/smallest” clue

We can now look at clue (3). We can think of this as just “there are two visibly-special bottles”, because there is no distinction between biggest and smallest. For each choice of two extreme-size bottles from seven, we can count how many of our above eight solutions are still valid, i.e., do not have “P” in either of the two special positions.

We can make a table, showing the two positions with extreme-size bottles, and the number of solutions possible with those positions:

01 : 002 : 303 : 204 : 305 : 006 : 4
12 : 113 : 114 : 015 : 216 : 2
23 : 324 : 425 : 126 : 6
34 : 335 : 136 : 5
45 : 046 : 5
56 : 2

For example, the entry “36:5” means that if the bottles in positions 3 and 6 are extreme-size, there are 5 solutions.

Solutions

We know that Hermione solved the puzzle, so the extreme-size bottles must be placed such that there is only one solution. (In fact it would also be OK if she could deduce that only the two (∗)’d solutions were possible, but this doesn’t happen.) There are four entries in the table with exactly one solution — 12:1, 13:1, 25:1, and 35:1.

If the extreme-size bottles are in positions 1 and 2 or 2 and 5, the only solution for both of these cases is in fact the same solution. Likewise for positions 1 and 3 or 3 and 5.

So the bottles must be arranged in one of these two ways:

— with 2 (the “forward” potion) and either 1 or 5 being extreme-size, or

— with 3 (the “forward” potion) and either 1 or 5 being extreme-size.

So we have worked out:

  • The “forward” potion is in either the smallest or the biggest bottle, and is in either position 2 or position 3; all four cases are possible.
  • The “backward” potion is at the right-hand end.

How the story unfolds

The text then says that Hermione works out that the “forward” potion is in the smallest bottle. This is consistent with what we’ve deduced. She also works out that the “backward” potion is in the rightmost bottle. We already knew that!

Answering our questions

The story around the puzzle is consistent.

We, the readers, can partially solve the puzzle even without being able to see the bottles.

Other discussions of this puzzle

I then looked on the web and was not too surprised to find that we were not the first people to think about this.

The Harry Potter fandom wiki has a page about this riddle, and gives a solution which involves the colours and sizes of the bottles, which must mean they’re using a different source for the puzzle, since no colours are mentioned in the book. The Pottermore fandom wiki has a page with an image using the colours described in the solution, so perhaps that’s it.

Shreevatsa R has a blog post (2012) going through a very similar process to the ours, but using Python to generate the (same) solutions. That post refers to a blog post (from 2001!) by Godric’s Ghost, which breaks the process down differently to how we did it, but, again, finds the same solutions.