
4 developers picking a random restaurant (Problem) - anudeep2011
https://lulucid.com/developers_picking_random_restaurant.html
======
gus_massa
> _2) I told each of the developers should run "echo $RANDOM" and then
> multiply them all._

This doesn't work very well, because the distribution would be very uneven.

There is a high chance (93.75%) that at least one of the developers get an
even number, so if you multiply them you will get an even result. Moreover, if
some of the developer get a multiple of 4 or two of them get a multiple of 2,
then the result is a multiple of 4, so the restaurants with a number that is a
multiple of 4 have a much higher probability (but I'm too lazy to do the
calculation now).

There is something similar with the restaurant that have an index that is a
multiple of 5 (and I'm still lazy). So the restaurant with the number 20 (or
0) has the highest probability of been selected.

As a though experiment, just imagine that you have 20 restaurants and 100
developers. It' almost sure that one of them will get a multiple of 4 and
another a multiple of 5, and the multiplication will be a multiple of 20.

The problem is that in the multiplication modulo 20, the numbers 2 (and 4) and
5 are special. If you _add_ the four random numbers instead of _multiplying_
them, the problem is automatically solved.

------
diego
Assume an ordered list of the restaurants [0-19]. Let's use the hash of the
first bitcoin block to be mined after (some time gmt) modulo 20 as index.
Done.

------
anudeep2011
My first own-content post on HN. Would love some feedback.

~~~
OMGWTF
Email: How do you prove that the server set the message id and not the client?

Github: How do you prove that the first commit was done with the web UI? And
how do you prove that there wasn't a force push replacing that commit?

------
cwkoss
Seems like you can just pre-announce any information source you do not control
and then take hash mod 20 once the content is made available.

Ex.

\- Next article title posted on NYT

\- Donald Trumps next tweet

\- Sum of tomorrow's lottery numbers, mod 20

~~~
viperscape
But that means waiting for the third party right?

~~~
TJSomething
You can use publicly available data feeds that changes every few minutes. For
example, CNN's Afterhours trading data [0] seems to work pretty well. And it's
just HTML, so you just hash it and you're good.

[0]
[http://money.cnn.com/data/afterhours/](http://money.cnn.com/data/afterhours/)

