Keep up the good work!

]]>(On Twitter it may or may not be more effective… it depends greatly. On Reddit it definitely is, although I don’t know how useful the responses to such a politically loaded question are going to be.)

]]>Thank you for your kind reply.

> After all, we are a community.

OK, I'm also one person of community.

Is is good to ask question for perl users and perl community?

]]>```

constant vanEck's = 0, {@_.end - (@_.head(*-1).first(@_.tail):end:k//(@_.end))}...∞;

```

Otherwise, we will get undefined error on `$N`.

]]>Thanks for spotting that.

I've corrected it in the text.

Much appreciated!]]>

With an initial share of 0.001 and 1,000 guests, I get:

Lucky guest: 32

Largest share: 0.0193839288860447

32 is more or less the square root of 1,000.

With 50 guests and an initial share of 0.2:

Lucky guest: 7

Largest share: 0.0902123937792

With 20 guests and an initial share of 0.5:

Lucky guest: 4

Largest share: 0.14535

When guest n comes in, the rest of the cake can be called r. So, guest n gets r * n/100. And what is left after guest n has been served is r - (r * n/100) = r * (100 - n) / 100.

Guest n+1 gets (r * (100 - n) / 100) * (n+1)/100. So guest n+1 gets more than guest n if r * (100 - n) / 100) * (n+1)/100 > r * n/100. Since r is a strictly positive number, we can remove r from both sides and simplify to (100 - n) / 100) * (n+1)/100 > n/100. This leads to: 100 - n² - n > 0. Or: n² + n = 10. So guest n+1 will get more than guest n for n

To find exactly where the function starts to decrease, we can solve the equation: -x² - x + 100 = 0. The discriminant is: delta = 1 + 400 = 401. The roots of the equation are: (1 +/- sqrt(delta) / -2. Disregarding the negative root, we get: x = -0.5 + sqtr(401)/2 = 0.5 + (sqrt(401)/2 = appprox. 10.5. Note that if we use other values (such as 50 guests and 2% shares), the equation will be the same except for the last term which will be 50 instead of 100. And the solution will be essentially the same, except that delta will be 201. This can thus be generalized to any number of guests.

Anyway, the point is that the math says (if I did not goof something in the computation) is that the discriminating factor is not exactly the square root of the number of guests, but half the square root of four times the number of guests + 1, which is pretty damn close, so that the approximation square root of the number of guests is probably good enough in practical terms for any number of guests larger than 2.

]]>... This leads to: 100 - n² - n > 0. Or: n² + n

]]>Oops, the end of the third paragraph of my previous reply got somehow cut.

... This leads to: 100 - n² - n > 0.

Or: n² + n less than 100.

We can easily see that guest n+1 will get more than guest n for n equal 3 to 9. In particular, for n = 9, guest 10 will get a larger share than guest 9. Subsequent guests will get less than their immediate predecessor and less than guest 10.

]]>