Last active
February 28, 2018 12:44
-
-
Save Yoiter/d4045ce2ef065c09e54af136ea1273dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh yes