Measure an Exact Volume with Two Jugs

Asked at Woven Planet · Coding Questions · Difficulty: Medium

You have two empty jugs that hold `a` and `b` liters and an unlimited water supply. The jugs have no markings, so the only amounts you can be sure of come from filling, emptying and pouring. Decide whether you can end up with exactly `target` liters of water, held in one jug or in the two jugs together.

Loading the problem…