Skip to content

Instantly share code, notes, and snippets.

@ybenjo

ybenjo/46.py Secret

Created October 27, 2018 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ybenjo/97684140c6d952e929b3ab3bcd767acd to your computer and use it in GitHub Desktop.
Save ybenjo/97684140c6d952e929b3ab3bcd767acd to your computer and use it in GitHub Desktop.
46 card challenge
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