Benjamin Juang (ibneko) wrote,
Benjamin Juang

For the record...

...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?

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment