Project Euler 172: Investigating numbers with few repeated digits
How many 18-digit numbers n (without leading zeros) are there such that no digit occurs more than three times in n?
Project Euler 172 SolutionRuns < 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(d-r, b-1)*binomial(d,r) for r in xrange(min(d+1, max_r+1))) return d <= max_r print "There are", nd(digits, base) * (base-1)/base, print digits, "digit numbers such that no digit occurs more than", max_r, print "times in base", baseUse this link to get the Project Euler 172 Solution Python source.
AnswerSlowly 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.
No afterthoughts yet.