by lutusp · 12y ago · 0 comments
Easily solved by taking the [EDIT: seconds digits] modulo the number of children, but I guess that might be difficult while driving.
EDIT: People, please try to think this through before posting an innumerate reply.
Edit: For instance, if there are 59 kids, the first one has twice as good a chance to win as any of the others, because both 0 % 59 and 59 % 59 are 0. In other words, in the set derived from x % 59, for x in {0, 1, ..., 59}, 0 appears twice, and each other number in the range 0-59 only appears once.
I never made the claim you're objecting to. The modulo operator minimizes the bias, it doesn't eliminate it. And it's the most efficient way to solve the problem.
My suggestion is that you stop thinking like a lawyer and start thinking like a scientist.
It's already solved. If there are 3 kids, 1-3 go to kid A, 4-6 to kid B, 7-9 to kid C, and 0 means try again. There's no bias present in this solution. Since it only takes a fraction of a second to generate a new digit with a stopwatch (using the hundredths of seconds digit) it's no big deal if you have to try five times.
Your solution introduces unnecessary arithmetic (what's 47 mod 3?) and unnecessary psychological pressure (will the kids start an argument while you're figuring it out? Will the ones who are better at math start taunting the others?) and it introduces bias in a family as large as ours got (7 or 8 kids can't evenly divide 60; 3, 6, or 7 kids can't evenly divide 100.)
A re-roll is simply a superior solution.
[Appeal to authority: my dad had a math degree and was valedictorian of his engineering college. I have bachelors and masters degrees in applied math. My oldest brother competed at the national level in Mathcounts. We all agree this is the best practical solution for this problem. Based on the votes, so does the bulk of the technically-minded Hacker News community.]
http://stackoverflow.com/questions/10984974/why-do-people-sa...
In other words, digit(s) modulo children.
"Try again" and "modulo" do not mean the same thing.
Try again means you discard a result outside of the range, and then generate a new number without any reference to the value of the first try. If you have 7 kids and you're picking 0-9, you discard any results of 7-8-9 (or 8-9-0) and try again.
Modulo means you take a result outside of the range, divide it by the range, and use the remainder (which is guaranteed to be in the range) as your new answer. The problem with this approach is that it's not evenly distributed -- if you have 7 kids and digits 0-9, three of your kids will get double chances. Even if you use 0-59 as your range, some of the kids will have 9 chances and others will have 8 chances.
n n % 4
-----------
0 0
1 1
2 2
3 3
4 0
5 1
6 2
7 3
8 0
9 1
10 2
11 3
12 0
13 1
14 2
15 3
EDIT: It must be really, really satisfying to be able to anonymously downvote posts that actually reveal such things as grade-school arithmetic -- thus contributing to the intellectual wasteland that most accurately represents America in the early 21st century.The pattern is clear and ubiquitous -- if you actually know something, and if you're foolish enough to post a clear exposition, the morons who never post anything coherent will downvote your posts with a probability approaching certainty.
The modulo operator is the obvious solution to the original question. And if there were't an atmosphere of pervasive anti-intellectualism at HN, this thread would be much shorted than it is.
Well it's not fair. Take 4 children for example. random 0 to 9 mod 4 does not have an even distribution over 0-4.
It's also more difficult to explain to children.
That's true, but only because 4 never appears in the result. The possible results for modulo 4 are 0 - 3.
The first child is numbered zero. Shall I explain it in more detail?
n n % 4
-----------
0 0
1 1
2 2
3 3
4 0
5 1
6 2
7 3
8 0
9 1
10 2
11 3
12 0
13 1
14 2
15 3
> It's also more difficult to explain to children.And rewarding, unless you want your children to grow up innumerate.
if the stopwatch uses hex, then 0-3 will appear equally often in this case
> if the stopwatch uses hex ...
I think we're safely in the red herring zone now. :)
EDIT: Yes, of course -- when confronted by a correct and reasoned reply, downvote it to discourage any such mistakes in the future.
Say I have 7 children and I get a number 0-9. If the result is 8, how does doing 8 mod 7 help me at all?
I invite you to locate where I posted an example in base 16.
> Say I have 7 children and I get a number 0-9. If the result is 8, how does doing 8 mod 7 help me at all?
Use both digital watch digits that tally seconds, as in my example.
Let's see how this turns out:
n n * 7 / 10
--------------
0 0
1 0
2 1
3 2
4 2
5 3
6 4
7 4
8 5
9 6
It's the same for most other numbers of children. Thanks for playing, no cigar.You haven't thought your reply through:
n n % 4
----------
0 0
1 1
2 2
3 3
4 0
5 1
6 2
7 3
8 0
9 1
10 2
11 3
12 0
13 1
14 2
15 3
> You want to multiply the last digit by the number of children and divide by ten.That doesn't produce the result you think it does. Think a bit harder. If the last digit is 20, and there are four children, the result is 4 * 20 / 10 = 8. There is no eighth child.
With a single generation, you can't uniformly choose from a set of n options with a random number generator that outputs m options, unless n divides m.
Digits, not digit. I doubt this fact will limit the number of airheads who downvote posts containing useful content.