Problem Description
Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468.
Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420.
We shall call a positive integer that is neither increasing nor decreasing a "bouncy" number; for example, 155349.
As n increases, the proportion of bouncy numbers below n increases such that there are only 12951 numbers below one-million that are not bouncy and only 277032 non-bouncy numbers below 1010.
How many numbers below a googol (10100) are not bouncy?
Analysis
Whenever a problem asks for the number of elements in a set, as does this one, then the solution in typically a counting problem solved with combinometrics.
Our solution uses the general formula that counts the monotonically increasing/decreasing digits ignoring leading zeros.
Solution
Runs < 1 second in Python.
from Euler import binomial n=100 print binomial(n+10,10) + binomial(n+9,9) - 10*n - 2
Comments
More information on the Euler module can be found on the tools page.





Discussion
No comments for “Project Euler Problem 113 Solution”