Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nice statistical problem! I only thought of a solution that is valid for many cars and few worksheet spots. Were you able to fully solve it on the spot?




What other situations are you concerned with that your solution doesn’t handle?

The best solution I could think of on the spot was this: First write down every license place until it fills up. Then for each time a car drives by, give it a 1/2 chance to write it down. Moving down the list regardless of the outcome. Then once the bottom is reached, do it again but with 1/3 a chance. Over and over again, decreasing the chance each time.

I checked for which situations it is valid, and it surprisingly was when there are many more cars than the list size. But it is not valid when there are just a few more cars than the list size.


Mine was to roll a number between 1 and N once N is greater than M (N being cars seen so far, M your slots available). If you get a number that is less than or equal to M, replace that slot. If it is greater than M, that sample is dropped.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: