# Ask The Wizard #394

You have a coffee cup that is initially empty. A waitress starts to pour coffee in it at a constant rate. Normally, with a good cup, it would take 5 seconds to fill the cup to the top. However, this cup has a leak at the bottom. Coffee leaks out at a rate proportional to the volume of coffee in the cup. When full, coffee leaks out at a rate of 0.1 cups per second.

How long does it take to fill the cup 90% of the way?

A basic understanding of differential equations is required for this solution.

Let:

V = volume of coffee in cup

t = time since waitress started pouring

c = constant of integration

We're given dV/dt = (1/5) - (v/10)

dv = (2-V)/10 dt

(10/(2-v)) dv = dt

-10*ln(2-v) = t + c

We know that at t=0, V=0. Plug those values into the equation above to solve for c:

c = -10*ln(2)

Our equation linking V and t is thus:

t = 10*ln(2) - 10*ln(2-V)

We want to know at what t is v=0.9. So solve for t when V=0.9.

t = 10*ln(2) - 10*ln(2-0.9) = 10*(ln(2) - ln(1.1)) = 10*ln(20/11)

How can I use six-sided dice to generate a random value from 0 to 36, each being equally likely?

There are various ways this can be done. However, I contend that all of them must have a possibility of a re-roll. My method below I believe is a simple method that requires only four dice of different colors and has a re-roll probability of under 0.08%. Here is how it works.

Call the dice d1, d2, d3 and d4. They are different colors, so you can tell them apart.

Define x = (d1-1) + 6*(d2-1) + 36*(d3-1) + 216*(d4-1). The value of x will range from 0 to 1,295.

Let y = random number we seek, where all 37 values from 0 to 36 are equally likely. Assign a value of y according to x, as follows:

- x = 0 to 34: y = 0
- x = 35 to 69: y = 1
- x = 70 to 104: y = 2
- x = 105 to 139: y = 3
- x = 140 to 174: y = 4
- x = 175 to 209: y = 5
- x = 210 to 244: y = 6
- x = 245 to 279: y = 7
- x = 280 to 314: y = 8
- x = 315 to 349: y = 9
- x = 350 to 384: y = 10
- x = 385 to 419: y = 11
- x = 420 to 454: y = 12
- x = 455 to 489: y = 13
- x = 490 to 524: y = 14
- x = 525 to 559: y = 15
- x = 560 to 594: y = 16
- x = 595 to 629: y = 17
- x = 630 to 664: y = 18
- x = 665 to 699: y = 19
- x = 700 to 734: y = 20
- x = 735 to 769: y = 21
- x = 770 to 804: y = 22
- x = 805 to 839: y = 23
- x = 840 to 874: y = 24
- x = 875 to 909: y = 25
- x = 910 to 944: y = 26
- x = 945 to 979: y = 27
- x = 980 to 1014: y = 28
- x = 1015 to 1049: y = 29
- x = 1050 to 1084: y = 30
- x = 1085 to 1119: y = 31
- x = 1120 to 1154: y = 32
- x = 1155 to 1189: y = 33
- x = 1190 to 1224: y = 34
- x = 1225 to 1259: y = 35
- x = 1260 to 1294: y = 36
- x = 1259: Re-roll

Note that only one value of x results in a re-roll.

I would especially like to thank Wizard of Vegas members ThomasK and ThatDonGuy for their help with this question. The above was ThomasK's solution. In the forum, ThatDonGuy proved that it's impossible to solve without mapping some rolls to a re-roll. See the link below for the whole discussion.

This question is asked and discussed in my forum at Wizard of Vegas.

Cards are drawn from a 52-card deck until a red card is seen. What is the average total cards drawn, including the one red card?

According to Wizard of Vegas member ThatDonGuy, if the total number of cards is c and the number of blockers is b, then the expected cards drawn is (c+1)/(b+1).

For example, in the question at hand c=52 and b=26, so the answer is 53/27.

If cars were drawn until an ace appeared, there would be four blockers, so the answer would be 53/5 = 10.6

This question is asked and discussed in my forum at Wizard of Vegas.