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 commandline 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 DAYSPERYEAR to Accept trials int as commandline argument Set count to For each t in trials Set birthdaysSeen to a list of size DAYSPERYEAR with all elements set to False use stdarray.createD Repeat forever Increment count by Set birthday to a random int from DAYSPERYEAR If birthday was seen before, break; otherwise, record that we are seeing it now Write counttrials use integer division
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
