Instantly share code, notes, and snippets.

What would you like to do?
Same Birthday Script
import random
num_people = 100
num_trials = 10000
for personCount in range(2,num_people+1):
trial_success = 0
for trialCount in range(0, num_trials):
birthdays = []
for person in range(0, personCount):
birthday = random.randint(1,365)
if birthday in birthdays:
trial_success += 1
birthdays.append(random.randint(1, 365))
percent_success = (float(trial_success) / float(num_trials))
print str(personCount) + "\t" + str(round(percent_success, 6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment