This assignment is worth 30 points.
A single trial for this simulation consists of adding people to a group until a duplicate birthday occurs. To do this, generate a random number between 0 and 364 (we will ignore leap year) to represent the day of the year on which a person was born, then check to see if this date matches any of the people already in the group.
Your program should conduct 2n trials, totaling the number of days for each trial. Once finished, the approximate average number of people can be calculated by shifting the total to the right by n.
You do not need to use floating point computations for this program.
You should prompt the user for the value of n
You should prompt the user for a verbosity level:
Verbosity Level | What is printed |
---|---|
0 | final answer |
The average number of people required for a duplicate birthday in 1024 trials is 23 | |
1 | One line per trial stating the person number and day number when the duplicate birthday occurred. |
Duplicate birthday at person 57 on day 126. | |
2 | One line per person per trial stating person number and birthday |
Person 1 has a birthday on day 102 |
You do not need to worry about efficiency of data storage. This problem could be done with bit operations, but that is not required, nor necessarily desired.
I would begin by writing a program in a high level language and translating this to assembly language.