You only have these three containers, all irregular in their shape (though it doesn´t appear in the simplified drawing below), with no marks in them, and all that you know is the capacity of each one.
The 3-liter is empty, the 5-liter is full of 50ºC water, and the 6-liter is full of 90ºC water.
|/////|
|/////| |/////|
|/////| |/90º/|
| | |/50º/| |/////|
| | |/////| |/////|
| | |/////| |/////|
+-----+ +-----+ +-----+
3-lit 5-lit 6-lit
With a succession of moves, how do you get some water at 76ºC? At 75ºC?
How many different integral temperatures, from 50ºC to 90ºC, can you get?
(In reply to
Computer exploration (spoiler?); is this it? by Charlie)
I left out the possibility that the contents of a container could be dumped out altogether. In the revised table, a "to" container labeled 0 is actually a dumping out of the "from" container:
2 1 / 3 2 / 2 3 / 2 0 / 3 2 / 1 3 / 58
2 1 / 2 0 / 3 2 / 1 3 / 60
3 1 / 2 3 / 3 2 / 62
2 1 / 3 2 / 2 3 / 2 0 / 3 2 / 1 3 / 3 1 / 2 3 / 3 2 / 1 3 / 63
3 1 / 3 0 / 2 3 / 1 2 / 3 1 / 1 2 / 2 3 / 3 1 / 1 2 / 64
3 1 / 2 3 / 3 2 / 1 3 / 3 1 / 3 0 / 2 3 / 1 3 / 65
3 1 / 2 3 / 3 2 / 2 3 / 66
3 1 / 3 0 / 2 3 / 1 2 / 3 1 / 1 2 / 1 0 / 2 3 / 3 1 / 1 2 / 2 3 / 67
3 1 / 1 0 / 2 3 / 2 1 / 3 2 / 2 1 / 1 3 / 3 2 / 68
3 1 / 2 3 / 3 2 / 2 3 / 2 0 / 3 2 / 1 3 / 3 1 / 2 3 / 69
3 1 / 2 3 / 70
3 1 / 2 3 / 3 2 / 1 3 / 3 1 / 2 3 / 71
3 1 / 2 3 / 1 2 / 3 1 / 2 3 / 72
3 1 / 2 3 / 1 2 / 2 1 / 2 0 / 3 2 / 1 3 / 73
2 1 / 3 2 / 74
3 1 / 2 3 / 2 0 / 3 2 / 1 3 / 2 3 / 3 1 / 2 3 / 75
3 1 / 2 3 / 3 2 / 3 0 / 1 3 / 2 3 / 76
3 1 / 2 3 / 2 0 / 3 2 / 1 3 / 2 3 / 3 1 / 1 2 / 2 3 / 77
3 1 / 2 3 / 3 2 / 2 0 / 3 2 / 1 2 / 78
3 1 / 2 3 / 2 0 / 3 2 / 1 3 / 2 1 / 3 2 / 79
3 1 / 2 3 / 3 2 / 1 3 / 80
2 1 / 2 0 / 1 2 / 3 1 / 1 2 / 2 3 / 3 2 / 1 3 / 81
2 1 / 3 2 / 2 3 / 82
3 1 / 2 3 / 3 2 / 2 3 / 2 0 / 3 2 / 1 3 / 84
3 1 / 2 3 / 2 0 / 3 2 / 1 3 / 85
2 1 / 1 0 / 2 1 / 3 2 / 2 1 / 1 3 / 3 2 / 86
The search was limited to at most 10 pourings/dumpings this time, due to time constraints.
DECLARE SUB choose ()
CLEAR , , 26000
DEFDBL A-Z
DIM SHARED cap(3), vol(3), temp(3), lvl
DIM SHARED hBestCt(51 TO 89)
DIM SHARED hBestS(51 TO 89, 20)
DIM SHARED hBestR(51 TO 89, 20)
cap(1) = 3: vol(1) = 0: temp(1) = 0
cap(2) = 5: vol(2) = 5: temp(2) = 50
cap(3) = 6: vol(3) = 6: temp(3) = 90
lvl = 0
DIM SHARED hSend(20), hRcv(20)
OPEN "water76.txt" FOR OUTPUT AS #2
choose
FOR i = 51 TO 89
IF hBestCt(i) > 0 THEN
FOR j = 0 TO hBestCt(i) - 1
PRINT USING "# # / "; hBestS(i, j); hBestR(i, j);
NEXT
PRINT i
END IF
NEXT
CLOSE
SUB choose
FOR s = 1 TO 3
FOR r = 1 TO 3
IF r <> s THEN
hSend(lvl) = s: hRcv(lvl) = r
IF vol(s) > 0 AND vol(r) < cap(r) THEN
amt = vol(s)
IF amt > cap(r) - vol(r) THEN amt = cap(r) - vol(r)
vol(s) = vol(s) - amt
tempSave = temp(r)
temp(r) = (temp(r) * vol(r) + temp(s) * amt) / (vol(r) + amt)
vol(r) = vol(r) + amt
IF temp(r) - INT(temp(r)) > .9999999000000001# OR temp(r) - INT(temp(r)) < .0000001# AND temp(r) > 50.5 AND temp(r) < 89.5 THEN
temp(r) = INT(temp(r) + .5)
FOR i = 0 TO lvl
PRINT #2, USING "# # / "; hSend(i); hRcv(i);
NEXT
PRINT #2, temp(r)
IF lvl < hBestCt(temp(r)) OR hBestCt(temp(r)) = 0 THEN
hBestCt(temp(r)) = lvl + 1
FOR i = 0 TO lvl
hBestS(temp(r), i) = hSend(i)
hBestR(temp(r), i) = hRcv(i)
NEXT
END IF
END IF
lvl = lvl + 1
IF lvl < 11 THEN
choose
END IF
lvl = lvl - 1
vol(s) = vol(s) + amt
temp(r) = tempSave
vol(r) = vol(r) - amt
END IF
END IF
NEXT
NEXT
FOR s = 1 TO 3
IF vol(s) > 0 THEN
volSave = vol(s)
vol(s) = 0
hSend(lvl) = s: hRcv(lvl) = 0
lvl = lvl + 1
IF lvl < 10 THEN
choose
END IF
lvl = lvl - 1
vol(s) = volSave
END IF
NEXT
END SUB
|
Posted by Charlie
on 2008-06-17 16:28:06 |