Created
April 26, 2019 11:31
-
-
Save Yossarian0916/0fcbaf0a61fb1ea34952359694823a0d to your computer and use it in GitHub Desktop.
how many girls should one date before he can be in a relationship with all 12 zodiac sign
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
""" | |
how many girls should one date before he can be in a relationship with | |
all 12 zodiac signs | |
""" | |
import random | |
def simulation(): | |
count = 0 | |
gf = set() | |
while len(gf) != 12: | |
girl = random.randint(1, 12) | |
gf.add(girl) | |
count += 1 | |
return count | |
def run(times): | |
total_count = 0 | |
for i in range(times): | |
count = simulation() | |
total_count += count | |
return total_count / times | |
if __name__ == '__main__': | |
res = run(50000) | |
print(res) | |
# the result should converge to 37.2385281 (12 × 𝐇₁₂, harmonic number) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment