-
-
Save ybenjo/97684140c6d952e929b3ab3bcd767acd to your computer and use it in GitHub Desktop.
46 card challenge
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 | |
random.seed(0) | |
TRIAL = 100000 | |
cards = [4] * 4 + [6] * 4 + [0] * 44 | |
dists = [ ] | |
for i in range(TRIAL): | |
random.shuffle(cards) | |
drawned = set() | |
for count, c in enumerate(cards): | |
if c == 4 or c == 6: | |
drawned.add(c) | |
if len(drawned) == 2: | |
dists.append(count + 1) | |
break | |
print(sum(dists) / TRIAL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment