Number of integers in a certain range with certain properties How would one (quickly) find the number of integers in the range [1, x] for some x, more than half of its digits being one digit, given that $x$ has at most, say, 19 digits. 

Brute force would obviously not work in a reasonable amount of time (where "reasonable" means roughly $10^9$ seconds)
Hint: Decompose the range $[1,x]$ into more manageable ranges of the form $[N\cdot 10^{k+1},N\cdot 10^{k+1} + d \cdot 10^k)$, where $d &lt; 10$. Enumerate over the "popular" digit, and use inclusion-exclusion.