Probability puzzle: what are the odds of a bad password?
The other day I got an email about an interesting probability problem:
Hi Presh -
I’m a regular reader of your site and I came across a question which has bugged me the last couple of days.
The problem is as follows: A system has 100 accounts, two of which have bad passwords (let’s call these bad accounts). If someone could only test 20 accounts, what are the chances that one will net a bad account?
It was inspired while reading the following post on StackOverflow regarding best practices for site authentication.
Thanks for any insights!
I spent a few minutes on the problem, and I was happy that I could solve it.
Can you figure it out?
I gave the issue more thought, and I came up with a few harder questions you can give a try.
Extensions:
1. What is the probability of netting both bad accounts in the sample of 20? What about exactly one bad account?
2. What is the probability of netting a bad account if you have k bad accounts, there are N total accounts, and you can sample n accounts at one time?
3. [Edit 8-15]: Go back to the problem with 100 accounts, and 2 bad accounts] Suppose you can vary how many accounts you can sample. If you want a 50 percent chance of netting a bad account, what’s the minimum sample size needed?
As usual, post your ideas/questions below.
[The only hint I will give is that I used numerical methods (namely WolframAlpha) to solve this.]
I will provide a solution on Wednesday in the comment section.
Share this post:
Previous post: 7 travel essentials for the bald man
Next post: Coin flipping game: how to make a fair toss from an unfair coin





