# Arup Guha
# 11/22/2019
# This program shows a simulation of the birthday paradox.

import random

# N is the number of people in the room, DAYS the number of
# possible birthdays, and NUMTRIALS how many times we repeat the
# simulation.
N = 45
DAYS = 365
NUMTRIALS = 100000

# Here is one simulation.
def sim():

    # Here I store how many birthdays of each day (frequency array)
    freq = [0]*DAYS

    # Simulate asking a person their birthday.
    for i in range(N):
        day = random.randint(0,DAYS-1)

        # Just add 1 to their day.
        freq[day] += 1

        # If this is more than 1 we have a birthday twin - success!
        if freq[day] > 1:
            return 1

    # If we get here it means there was no birthday twin.
    return 0

# This just runs the trials and prints out the experimental probability that
# two people in a room with N people share the same birthday.
def main():
    success = 0
    for i in range(NUMTRIALS):
        success += sim()
    print(100*success/NUMTRIALS)

# Go!
main()
