Problem 1372. Miles to go before I sleep
Recently, my car's odometer passed 56789. Given an odometer reading, output how many miles need to be driven to get the next mileage made up of consecutive increasing numbers. If the mileage is already made up of consecutive digits, output 0.
Use the digits 0-9 only. For example, if your odometer is at 67903 miles, your script should output 10998, which is the number of miles needed to reach 78901 (7-8-9-0-1), rather than 78910 (7-8-9-10).
You may need to increase the number of digits in your odometer reading to accomplish this task. For example, a reading of 9843 means that you will need to travel 2502 miles to get to 12345. However, a reading of 9011 needs only one more mile to get to 9012.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers35
Suggested Problems
-
Find the sum of all the numbers of the input vector
47684 Solvers
-
6204 Solvers
-
The Hitchhiker's Guide to MATLAB
3274 Solvers
-
Find the elements of a matrix according to a defined property.
84 Solvers
-
102 Solvers
More from this Author80
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!