Inspired by Project Euler n°112.
- 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.
Clearly there cannot be any bouncy numbers below one-hundred, but surprisingly, these numbers become more and more common after.
Find the least number for which the proportion of bouncy numbers is exactly p%.
As always this type of problem is difficult to solve with usual Matlab functions (num2str).
So keep an eye on time...
Solution Stats
Problem Comments
3 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers46
Suggested Problems
-
Split a string into chunks of specified length
2159 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
14449 Solvers
-
566 Solvers
-
Find last zero for each column
735 Solvers
-
Remove element(s) from cell array
2123 Solvers
More from this Author43
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
I think the problem statement should read "the proportion of bouncy numbers is at least p%", rather than "exactly p%."
Currently, num2str is able to handle all test cases.
Perhaps num2str was too slow when the problem was initially posted. Many built-in functions have undergone significant performance improvements over the years.