Project Euler 172: Investigating numbers with few repeated digits
How many 18digit numbers n (without leading zeros) are there such that no digit occurs more than three times in n?
Project Euler 172 Solution
Runs < 2 seconds in Python.from Euler import binomial
digits, base, max_r = 18, 10, 3
def nd(d,b):
if b>1:
return sum(nd(dr, b1)*binomial(d,r) for r in xrange(min(d+1, max_r+1)))
return d <= max_r
print "There are", nd(digits, base) * (base1)/base,
print digits, "digit numbers such that no digit occurs more than", max_r,
print "times in base", base
Use this link to get the Project Euler 172 Solution Python source.Answer
Slowly swipe from either end beginning with the white vertical bar to get an idea of the starting or ending digits. For less drama, just double click the answer area. The distance between the two bars will give you an idea of the magnitude. Touch devices can tap and hold the center of the box between the two bars and choose define to reveal the answer.227485267000992000
Afterthoughts

No afterthoughts yet.
Discussion
No comments yet.