The next part asks how much Jeremy's advantage increases by if you increase the number of cakes. You might say, have 7 cakes. Would Jeremy still come out ahead using the rules in the previous challenge?

I just used some extrapolation to do this one. It's not quite as thorough as the solution in the book, but we end up at the same place. First, I looked at the case where there are two cakes, n = 2. Then Jeremy's advantage over Marie is 5/4 - 3/4 = 1/2. Next, I looked at the case where there are three cakes, n = 3. Then Jeremy's advantage over Marie is 15/8 - 13/8 = 2/8 = 1/4. You can keep increasing n and you will see a trend, which works out to the following equation: A = 1/2

^{(n-1)}.

I wrote a little code in C++ to let us easily extrapolate:

#include "stdafx.h" #include "math.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { double advantage; int numCakes; cout << "Enter number of cakes: "; cin >> numCakes; advantage = 1.0/(pow(2.0, numCakes - 1)); cout << "Jeremy's advantage is: " << advantage << endl; return 0; }

The question then asks if there's a way to make sure both players of this game get an equal amount of the cake. That part is easy! As we noticed when Marie goes first, Jeremy always cuts that cake in half. If she can always go first, they'll always get an equal amount of cake.

## No comments:

Post a Comment