-
-
Save oskarols/497a73f2d3001f401f38 to your computer and use it in GitHub Desktop.
Chance of duplicates in deck — Python
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 as r | |
a=range | |
l=len | |
d=list(a(1,15))*4 | |
t=[] | |
for i in a(1000000):r.shuffle(d);t.append(int(any(d[i]==d[i+1]for i in a(l((d)))if i<55))) | |
print(sum(t)/l(t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gillade
shuffle(l) or 0 in
samt användandet avzip
. Snyggt!