Measuring two pints
You have a -pint and an -pint vessel and an unlimited water source. You must end with exactly pints in a vessel. A single "transaction" is filling a vessel to the top, emptying a vessel completely, or pouring one vessel into the other until the source is empty or the destination is full. What is the minimum number of transactions needed?
Show hints (2)+
- Model states and do a breadth-first search; each fill/empty/pour is one transaction.
- The shortest path to a vessel holding takes moves.
Answer
Reveal answer →Final answer
14
Want the full step-by-step worked solution? It's part of Premium - along with a worked solution for every question in the bank.
Asked at: Jane Street, Optiver