Problem 44637. Still more miles to go before I sleep
It's time for more odometer fun. Last problem, my car's odometer hit 56789. It's coming up on 111111 now, which (barring a major miracle) will be the last binary number to ever show up on the odometer. You will be given two numbers - an odometer reading, and a number base. Calculate the number of miles your car will need to travel in order to show the next number that is valid in that base. If your odometer reading is already a valid number in that base, return 0.
For example, your input is an odometer reading of 12341 with a number base of 4. The next odometer reading that would be valid in base 4 is 13000, so the correct answer would be 13000-12341, or 659.
You can assume that the odometer reading is in base 10, the input is numerical and not a string, all numbers will be positive integers, and that your car will last that long without getting read-ended at a stop-light. Happy driving!
Solution Stats
Problem Comments
Solution Comments
Show commentsGroup

Basics - Rounding
- 10 Problems
- 2676 Finishers
- Find the sum of all the numbers of the input vector
- Maximum value in a matrix
- Make the vector [1 2 3 4 5 6 7 8 9 10]
- Return area of square
- Select every other element of a vector
- Triangle Numbers
- Check if number exists in vector
- Create times-tables
- Determine whether a vector is monotonically increasing
- Roll the Dice!
- Verify Law of Large Numbers
- Solve a System of Linear Equations
Problem Recent Solvers47
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!