All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Water at 76º C (Posted on 2008-06-17)
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?

 See The Solution Submitted by pcbouhid Rating: 4.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 aha!; now I've got it (spoiler) | Comment 2 of 5 |
(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                                /  582 1 / 2 0 / 3 2 / 1 3                                            /  603 1 / 2 3 / 3 2                                                  /  622 1 / 3 2 / 2 3 / 2 0 / 3 2 / 1 3 / 3 1 / 2 3 / 3 2 / 1 3        /  633 1 / 3 0 / 2 3 / 1 2 / 3 1 / 1 2 / 2 3 / 3 1 / 1 2              /  643 1 / 2 3 / 3 2 / 1 3 / 3 1 / 3 0 / 2 3 / 1 3                    /  653 1 / 2 3 / 3 2 / 2 3                                            /  663 1 / 3 0 / 2 3 / 1 2 / 3 1 / 1 2 / 1 0 / 2 3 / 3 1 / 1 2 / 2 3  /  673 1 / 1 0 / 2 3 / 2 1 / 3 2 / 2 1 / 1 3 / 3 2                    /  683 1 / 2 3 / 3 2 / 2 3 / 2 0 / 3 2 / 1 3 / 3 1 / 2 3              /  693 1 / 2 3                                                        /  703 1 / 2 3 / 3 2 / 1 3 / 3 1 / 2 3                                /  713 1 / 2 3 / 1 2 / 3 1 / 2 3                                      /  723 1 / 2 3 / 1 2 / 2 1 / 2 0 / 3 2 / 1 3                          /  732 1 / 3 2                                                        /  743 1 / 2 3 / 2 0 / 3 2 / 1 3 / 2 3 / 3 1 / 2 3                    /  753 1 / 2 3 / 3 2 / 3 0 / 1 3 / 2 3                                /  763 1 / 2 3 / 2 0 / 3 2 / 1 3 / 2 3 / 3 1 / 1 2 / 2 3              /  773 1 / 2 3 / 3 2 / 2 0 / 3 2 / 1 2                                /  783 1 / 2 3 / 2 0 / 3 2 / 1 3 / 2 1 / 3 2                          /  793 1 / 2 3 / 3 2 / 1 3                                            /  802 1 / 2 0 / 1 2 / 3 1 / 1 2 / 2 3 / 3 2 / 1 3                    /  812 1 / 3 2 / 2 3                                                  /  823 1 / 2 3 / 3 2 / 2 3 / 2 0 / 3 2 / 1 3                          /  843 1 / 2 3 / 2 0 / 3 2 / 1 3                                      /  852 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

 Search: Search body:
Forums (0)