Joke of the day:
Local Insane Asylum.
Time for their Yearly review by the state.
State Inspector shows up and talks to the Asylums administrator. They chat for a while, go over some numbers and then the inpector say, "Everything seems in order, i just need to go around and do a visual inspection of some of the patients."
"Follow me," says the administrator.
They...
Read More
hbfm said:
I think if you read up on Golomb rulers you will find a general structure similar to the 4 gallons problem. If you'd like to share spare clock cycles, ala SETI@Home, there are distributed projects searching for optimum GRs. As is to be expected from NP-complete problems, they're forced to brute a solution.
that's it.
and brute force isn't the only way. check out vazirani's book _approximation algorithms_ and learn to navigate the search space.
mistermocha said:
Let's call the five gallon bucket A and the three gallon bucket B.
1) Fill bucket A completely.
V(A) = 5
V(B) = 0
2) Fill bucket B with water until it is full. Bucket A will have 2 gallons remaining.
V(A) = 2
V(B) = 3
3) Dump out B, and put the 2 gallons from A into B.
V(A) = 0
V(B) = 2
4) Fill bucket A with some amount more than 2 gallons.
V(A) = 2+
V(B) = 2
5) Depress bucket B into the water in bucket A. When the tops of the buckets are level and the excess water has brimmed over, then the volume of bucket A will contain 2 gallons of water, with 3 gallons displaced by bucket B
V(A) = 2
V(B) = 2
V(A) + V(B) = 4
A better, perhaps easier way of doing this, since you don't have to "eye" the 2 buckets to see if they're even is to fill the 3 gallon bucket first. Empty it into the 5 gallon bucket. Then fill the 3 gallon bucket again, and fill the 5 gallon to the top, leaving 1 gallon in the 3 gallon bucket. Now empty the 5 gallon bucket, and then pour the 1 gallon into the 5 gallon bucket. Fill the 3 gallon bucket, and pour it into the 5 gallon bucket, which has 1 gallon in it already and you have 4 gallons.
I think that's how they did it in Die Hard.