Skip to content

Instantly share code, notes, and snippets.

@Yoiter
Last active February 28, 2018 12:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yoiter/d4045ce2ef065c09e54af136ea1273dc to your computer and use it in GitHub Desktop.
Save Yoiter/d4045ce2ef065c09e54af136ea1273dc to your computer and use it in GitHub Desktop.
import random
birthday = 0
birthdays = []
counter = 0
simulations = 100000
for i in range (simulations):
for i in range (23):
birthday = random.randrange(365)
birthdays.append(birthday)
duplicates = [x for n, x in enumerate(birthdays) if x in birthdays[:n]]
if len(duplicates) != 0:
counter = counter + 1
birthdays = []
duplicates = []
print(counter/simulations*100,"%")
#resource: https://stackoverflow.com/questions/9835762/find-and-list-duplicates-in-a-list
@whybruh
Copy link

whybruh commented Feb 28, 2018

oh yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment