11
1
Lets create a system of numbers where the biggest digit in the nth place value (counting from right to left) of a number length m is always equal to m - n + 1. To give an example the largest 5 digit number expressible in this system is written 12345. Apart from the number of digits available to be used in a particular place being restricted, all other incrementation is standard. Namely when a digit is to surpass its digit limit we add one to the next digit.
Here is how counting would be represented in this system:
1; 10; 11; 12; 100; 101; 102; 103; 110; 111; 112; 113; 120; 121; 122; 123; 1000; 1001 ...
Your task is to write a function that takes a standard base 10 number and converts it to my numbering system.
Shorter code is preferable. Bonne Chance!
**If you need digits after 9 (you should) you can choose to use letters, or you can you return a 2 digit number as an element of a list.
Test Cases
10 -> 111
20 -> 1003
30 -> 1023
50 -> 1123
100 -> 10035
23116 -> 1234567
21977356 -> 123456789A
Last case may be incredibly slow to run depending on how you implemented. You don't need to run it if it takes too long or uses too much memory. However note that there exist ways to have it run quickly and using little memory.
Given your last comment, is it okay if we always return a list with the digits? – Greg Martin – 2017-01-13T02:12:20.757
Yes, That's a reasonable way to give output, as long as the numbers are correct – Ando Bando – 2017-01-13T02:13:40.853
1I'm getting
100 -> 10035
rather than100 -> 10033
, can you verify? – Greg Martin – 2017-01-13T02:26:18.807@GregMartin 10035 seems right. I did my calculations by pen and not program and hence made a computation error. I guess we have computers for a reasom – Ando Bando – 2017-01-13T02:28:06.723
Can we assume all inputs are positive integers? – smls – 2017-01-13T11:20:20.273
Also, you should really add a test-case that demonstrates the case of a digit greater than 9. – smls – 2017-01-13T11:49:00.380
1
Maybe duplicate? http://codegolf.stackexchange.com/questions/11735/convert-to-and-from-the-factorial-number-system?rq=1
– G B – 2017-01-13T12:52:17.683@smls That's a fair assumption – Ando Bando – 2017-01-13T13:18:17.487