Lore
Potion riddle
The potion riddle was created by Severus Snape to prevent anyone from getting…

Brilliant. This isn't magic — it's logic — a puzzle. A lot of the greatest wizards haven't got an ounce of logic, they'd be stuck in here for ever.
The potion riddle was created by Severus Snape to prevent anyone from getting the Philosopher's Stone, featured as the sixth obstacle in the Underground Chambers.
Description

Everything we need is here on this paper. Seven bottles: three are poison; two are wine; one will get us safely through the black fire and one will get us back through the purple.
After entering the chamber, the person would be trapped between black flames blocking the path ahead and purple flames blocking the way back. Seven potions were aligned in front of the reader, each one a different colour. From left to right, they were: white, red, blue, yellow, green, black, and purple. Additionally, each potion bottle was a different size; from tallest to smallest, the order was: black, yellow, red, purple, white, green, and blue. The person who entered the chamber would need to figure out which bottle contained what. The clue to solving the physical riddle was written on a roll of paper. The reader would have to solve the riddle to figure out the correct potions needed to safely pass through the flames. The riddle could have been considered as hard but solvable, with enough clues to lead to the right solution. Hermione Granger noted, to get past this obstacle required intelligence and logic, regardless of one's own magical ability and power.
Transcript
"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 for evermore, 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 onwards 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."
Solution
The blue bottle contained the potion to go ahead through the black flames, while the purple bottle was the one that would let one go back through the purple flames. The red and black bottles were wine. The white, green, and yellow bottles contained poison.
Using the information given in the riddle, one method to deduce the identity each bottle was by processes of elimination:
From the fourth clue, the red bottle (second from the left) and black bottle (second from the right) both contained the same thing. Therefore, the potions to go ahead and go back could be ruled out, as there was only one of each. From the third clue, the black bottle (the largest one) did not contain poison. Therefore, the red and black bottles could only be nettle wine. Therefore, from the first clue, the white and green bottles (to the left of nettle wine) are poison. From the second clue, since the white bottle on one end contained poison, the purple bottle on the opposite end must be something other than poison, nor could it have been the potion to go ahead, and since both bottles of wine were already known, the purple bottle could only be the potion to go back. From the third clue, the blue bottle (the smallest one) cannot be poison, and since the wine and the potion to go back were already known, it could only be the potion to go ahead. Which left the yellow bottle as the last remaining bottle of poison.
Another option was to use the information given in the riddle to first identify the poisons since the process of elimination concurrently identifies the wine and potions:
According to the third clue, neither the tallest (black) nor the smallest (blue) bottles contain poison. However, as the fourth clue reveals that the red and black potions are the same, this also eliminates the red bottle and identifies them both as nettle wine. With four potions remaining and the nettle wines determined, the first clue said that a potion to the left of nettle wine is always a poison. This reveals that the white and green bottles must be poisons as they are both to the left of a nettle wine. The second clue said that the white and the purple bottle does not contain the same thing, meaning that the purple bottle could not be a poison. The third clue says that the blue bottle is not a poison. This leaves only the yellow bottle to contain the last of the three poisons. With all the poisons and nettle wines identified, this leaves the blue and purple bottles as the correct potions. The second clue reveals that the potion on the far right end (the purple bottle) does not allow one to move forward. Therefore, the blue bottle can only be the potion to go forward and the purple bottle to go back.
Reconstruction based on the book
The book doesn't specify which bottle is the smallest and which is the tallest. However, based on the rules and Hermione's answers in the book, assuming that she doesn't have to guess, we can reconstruct which configurations are possible. The configuration consistent with the other sources is written in bold.
Shortest: 3rd bottle, Tallest: 2nd or 6th bottle. Bottle order: Poison, Wine, Potion allowing to go Forward, Poison, Poison, Wine, Potion allowing to go Backward
Shortest: 4th bottle, Tallest: 2nd or 6th bottle. Bottle order: Poison, Wine, Poison, Potion allowing to go Forward, Poison, Wine, Potion allowing to go Backward.
The size of the other bottles doesn't matter.
We can arrive to these solutions with either a long case-logic on a piece of paper or via programming. We can write a program which enumerates all configurations and filters the ones which are compatible with the text of the book.
Sources
Adapted from the original article, under CC BY-SA 3.0.







