"Brilliant," said Hermione. "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 forever."
"But so will we, won't we?" "Of course not," said Hermione. "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."

Harry Potter and the Philosopher's Stone - Chapter 16 : Through the Trapdoor
See this quote in the Pensive -