I need to prepare digits made of cardboard to display some number (example). I don't know beforehand which number I should display - the only thing I know is that it's not greater than n
.
How many cardboard digits should I prepare?
Example: n = 50
To display any number in the range 0...50, I need the following digits:
- A zero, for displaying the number 0, or any other round number
- Two copies of digits 1, 2, 3 and 4, for displaying the corresponding numbers
- One copy of digits 5, 6, 7 and 8, for the case they appear as least significant digit in the number
- The digit 9 is never needed, because I can use the inverted digit 6 instead
Total: 13 digits
Test cases (each line is a test case in the format "input; output")
0 1 1 2 9 9 11 10 50 13 99 17 100 18 135 19 531 22 1000 27 8192 34 32767 38