Skip to content

Instantly share code, notes, and snippets.

@DuncanHills
Forked from philihp/fourkind.py
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DuncanHills/2e1fd462f2a3f4115b0c to your computer and use it in GitHub Desktop.
Save DuncanHills/2e1fd462f2a3f4115b0c to your computer and use it in GitHub Desktop.
from collections import defaultdict
from collections import defaultdict
n = 8
k = 4
good = 0;
for x in xrange(10**n - 1):
s = str(x).zfill(8);
a = defaultdict(int)
for c in list(s):
a[c] += 1;
if k in a.values():
good += 1;
print float(good)/float(10**n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment