For the record...
Feb. 21st, 2008 04:51 pm...I still hate interviews.
Especially ones that ask me to recall things like the best sorting method... :P Fucking algorithms. Especially when the last time I saw them was 3+ years ago...
That being said, I did manage to get a rather curious problem out of that interview. So, given a random number generator that can only give you 0 and 1, what's the fastest way of extracting a fair 0, 1, or 2? (err, so you have a 1/3 chance of getting 0, 1/3 chance of getting 1, 1/3 chance of getting 2.)
roll it two times:
If we get 00, 01, 10 we pick a, b, or c respectively. Otherwise, we reroll twice. Is there a better way to do this?
Especially ones that ask me to recall things like the best sorting method... :P Fucking algorithms. Especially when the last time I saw them was 3+ years ago...
That being said, I did manage to get a rather curious problem out of that interview. So, given a random number generator that can only give you 0 and 1, what's the fastest way of extracting a fair 0, 1, or 2? (err, so you have a 1/3 chance of getting 0, 1/3 chance of getting 1, 1/3 chance of getting 2.)
roll it two times:
If we get 00, 01, 10 we pick a, b, or c respectively. Otherwise, we reroll twice. Is there a better way to do this?