Question: ( Birthday Problem ) Suppose that people enter an empty room until a pair of people share a birthday. On average, how many people will

(Birthday Problem) Suppose that people enter an empty room until a pair of people share a birthday. On average, how many people will have to enter before there is a match? Write a program called birthday.py that accepts trials (int) as command-line argument, runs trials experiments to estimate this quantity each experiment involves sampling individuals until a pair of them share a birthday, and writes the value to standard output. Set DAYS_PER_YEAR to 365 Accept trials (int) as command-line argument Set count to 0 For each t in [0,trials)- Set birthdaysSeen to a list of size DAYS_PER_YEAR with all elements set to False (use stdarray.create1D())- Repeat forever- Increment count by 1- Set birthday to a random int from [0,DAYS_PER_YEAR)- If birthday was seen before, break; otherwise, record that we are seeing it now Write count/trials (use integer division)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!