-
-
Save DuncanHills/2e1fd462f2a3f4115b0c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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