Answer:
Here’s a way to solve this:
(7/7,4/4,0/10) Æ (7/7, 0/4, 4/10) Æ(1/7, 0/4, 10/10) Æ (1/7, 4/4, 6/10), (5/7, 0/4, 6/10) Æ
(5/7, 4/4, 2/10) Æ (7/7, 2/4, 2/10), hence we end up with 2 pints in the 4‐pint container
.
To model this as a graph problem, we represent each potential state of the three containers with an
ordered pair (A,B), where A represents the amount of water in the 7‐pint container and B represents the
amount of water in the 4‐pint container.
Hence the initial state would be(7,4). Note that we do not need an ordered triple as we know the total
amount of water in all three containers (11 pints). Therefore, the total state is completely determined by water in
the 7 and 4 pint containers.
Hence, we have 5 x 8 = 40 possible states for the system. We model these
states as nodes in a directed graph and draw an edge from one node to another node if we can go from
the configuration represented by one node to the configuration represented by another node through
one pour.
For example, there would be an edge from (7,4) to (0,4) but no edge from (1,3) to (5,1).
Thus, if we can find a path from one node to another, then we can go from one state to another
through a series of pourings. The nodes are represented in the attached file (the edges are left out).
Explanation:
Since we want to find
a path from (7,4) to one of the nodes contained in one of the rectangles. Our solution above is
depicted in the attached file
Looking at the graph in attachment, we will start at node (7,4) and run DFS to see if we can reach one of the nodes boxed by a rectangle (i.e. has 2 as one of the coordinates). If we can, then there is a solution.
Otherwise, there is no way to have two liters in one of the containers through a series of pouring from
the original state of (7/7,4/4,0/10).