Skip to content

Instantly share code, notes, and snippets.

@oskarols
Last active August 29, 2015 14:00
Show Gist options
  • Save oskarols/497a73f2d3001f401f38 to your computer and use it in GitHub Desktop.
Save oskarols/497a73f2d3001f401f38 to your computer and use it in GitHub Desktop.
Chance of duplicates in deck — Python
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))
@oskarols
Copy link
Author

Gillade shuffle(l) or 0 in samt användandet av zip. Snyggt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment