# Arup Guha
# 11/8/2023
# Simulation of Weak Collision Resistance

import random

NUMTRIALS = 10000

# n = # of total days
# k = # of people in the room
def sim(n,k):

    fixedday = random.randint(1,n)

    hit = 0

    # Try generating k random integers in range.
    for i in range(k):
        cur = random.randint(1,n)

        # Got a match.
        if cur == fixedday:
            hit = 1
            break

    # Returns 1 if fixed birth day matched, 0 otherwise.
    return hit

# Run simulations with n days and k other people trying to match a birthday.
def runsim(n, k):

    # Add up # of successes.
    success = 0
    for i in range(NUMTRIALS):
        success += sim(n, k)

    # Here is the experimental probability.
    return success/NUMTRIALS;

# Jack won a dollar coming the closest on this prediction.
simprob = runsim(365, 100)
print(simprob, 100/365)
