Bouncy numbers - MATLAB Cody - MATLAB Central

Problem 42377. Bouncy numbers

Difficulty:Rate
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

35.25% Correct | 64.75% Incorrect
Last Solution submitted on Jun 03, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
2
3

Problem Recent Solvers39

Suggested Problems

More from this Author43

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!