A superstitious car maker built an odometer that never shows the digit 4. It counts
0, 1, 2, 3, 5, 6, ... and every time the next reading would contain a 4 anywhere, that reading is
skipped: after 39 it shows 50, after 399 it shows 500, and after 139 it shows 150.
The odometer started at 0 and moves up by exactly one reading per kilometre. Write
true_distance(shown) that returns how many kilometres the car has really driven when the
display reads shown. If shown contains the digit 4, the display is broken: return -1.
Examples
Input: shown = 15
Output: 13
Explanation: the readings are 0,1,2,3,5,6,7,8,9,10,11,12,13,15, so 15 is the 13th km.
Input: shown = 50
Output: 36
Input: shown = 1234
Output: -1
Constraints
0 <= shown <= 10**15
Goals
- Peel digits off a number with % and //
- Rebuild a value from its digits with a different place value
- Spot that a counting rule is really a number system