Convert decimal numbers to a base-9 notation missing the digit 5
Too many five-themed problems? Wondering whether everything would be simpler if we just got rid of the digit 5? Let's try!
In a world without 5's, positive integers may be represented using a base-9 notation that uses only the digits 0, 1, 2, 3, 4, 6, 7, 8, and 9. We'll call this the "missing-5" notation. The following list shows the first 100 positive numbers (i.e. 1 through 100) using "missing-5" notation:
'1' '2' '3' '4' '6' '7' '8' '9' '10' '11' '12' '13' '14' '16' '17' '18' '19' '20' '21' '22' '23' '24' '26' '27' '28' '29' '30' '31' '32' '33' '34' '36' '37' '38' '39' '40' '41' '42' '43' '44' '46' '47' '48' '49' '60' '61' '62' '63' '64' '66' '67' '68' '69' '70' '71' '72' '73' '74' '76' '77' '78' '79' '80' '81' '82' '83' '84' '86' '87' '88' '89' '90' '91' '92' '93' '94' '96' '97' '98' '99' '100' '101' '102' '103' '104' '106' '107' '108' '109' '110' '111' '112' '113' '114' '116' '117' '118' '119' '120' '121'
You may notice that this is simply the sorted list of positive numbers which do not contain the digit 5 in their decimal representation.
Your function should convert a positive decimal number N into its "missing-5" notation. For example
dec2missing5(20)
should return '22' (the 20th positive number in missing-5 notation), and
dec2missing5(100)
should return '121' (the 100th positive number in missing-5 notation)
Good luck!
Small print: Your function may output a number, a char array, or a string; whatever you find simpler (e.g. in the example above, valid outputs are 121, '121', or "121"). Input numbers in testsuite are always relatively low valued positive integers (<10,000)
Too bad this problem number has a '5' in it! :-)
Any suggestions on my brute force method?
sorry, I added a couple of test cases to discourage this sort of solutions
Sort a list of complex numbers based on far they are from the origin.
3994 Solvers
Which values occur exactly three times?
3491 Solvers
Make a run-length companion vector
471 Solvers
Simple equation: Annual salary
3542 Solvers
418 Solvers