12
1
The nutty maths professor wants to encode all of their research using a system sure to fox even the wiliest of their competitors!
To this end the professor has decided to change the base of not just the number that they're writing but every single digit in that number, according to which place the digit finds itself in (counting from the right, starting with 1). For example:
The number 0 has one digit, so it is represented in base 1: 0
The number 1 would have one digit in base ten, but in our professor's system that isn't valid. The first place is reserved for base 1 digits only! This means it must be bumped to the second place where base 2 is allowed: 10
The number 2 requires at least base 3 to be written: 100
But now the number 3 can be written by changing the digit in the second place: 110
and 4 as so: 200
Here are some more examples to help you get the idea:
5:210
6:1000
7:1010
8:1100
9:1110
10:1200
11:1210
12:2000
13:2010
14:2100
15:2110
16:2200
17:2210
18:3000
Using this system the professor's notes will make no sense to anyone but them, and they can finally take over the world!!!! sleep well at night.
Of course the encoding method must be as obscure as possible.
Your task is to write 10 code snippets, each representing one of the base 10 digits
0 1 2 3 4 5 6 7 8 9
which when combined in the order of the number to be converted will produce a number written in the professor's diabolical numbering system (the output method may be of your choice but must be a human readable number using only the digits 0-9)
For example if my snippets are:
0=MONKEY 1=EXAMPLE, 2=CODE, 3=GOLF and 9=TEST
then
19 = EXAMPLETEST -> 3010
20 = CODEMONKEY -> 3100
21 = CODEEXAMPLE -> 3110
22 = CODECODE -> 3200
23 = CODEGOLF -> 3210
No input numbers with more than 10 digits or negative numbers need to be considered, though if you want to write the code for additional digits you will get extra kudos. This is code golf, so shortest answer (using the combined byte totals of all snippets) wins and the standard loopholes aren't allowed.
ADDENDUM: Before anyone gets started on whether 0 is the correct representation of 0 in base 1 I would like to remind you that this professor is nutty. Live with it.
1
Note: The professor's system is also known as the factorial number system.
– ETHproductions – 2016-12-21T14:57:46.853It's also OEIS A124252
– user41805 – 2016-12-21T15:02:52.887@ETHproductions I never said the Professor's encoding was good. – Joe Bloggs – 2016-12-21T15:06:32.350
@KritixiLithos Thank you for that! I was looking for that to use as confirmation. – Joe Bloggs – 2016-12-21T15:07:41.973
4Welcome to PPCG, by the way :-) – ETHproductions – 2016-12-21T15:10:28.603
@ETHproductions: Thanks. I must confess to being a long time lurker... – Joe Bloggs – 2016-12-21T15:12:26.750
You state: "Your task is to write 10 code snippets, each representing one of the base 10 digits". Later, it seems that you want a conversion of a decimal number into a factorial base system. Do you want "snippets" in English, or simply the conversion? – DavidC – 2016-12-21T16:00:32.587
@DavidC: The code snippets are combined in order to act as the input to be converted, as shown in the example. There is already a factorial conversion challenge, but this is mostly about the novel input format. – Joe Bloggs – 2016-12-21T16:02:27.543
Is including code outside of the snippets permitted as well? Or does all code used have to be in a snippet? – Tutleman – 2017-01-30T20:42:32.110
@Turtleman: All code should be in the snippet. – Joe Bloggs – 2017-01-30T20:44:50.237
There is a lot of gender bias in mathematics. Assuming that a maths professor is male (as you do in the first sentence) not only is a symptom of our implicit bias, but also reinforces that harmful bias. I encourage you not to assign genders to hypothetical STEM people. – Greg Martin – 2017-02-12T19:02:04.833
What do you want the output to be if the snippets indicate the number 36288000, which is 10 times 10! and thus has a two-digit "digit"? – Greg Martin – 2017-02-12T19:28:13.880
@GregMartin: Feel free to edit to a gender neutral or fluid pronoun if you really want to. I was just going to assign the gender of the next hypothetical professor based on a coin flip. – Joe Bloggs – 2017-02-12T21:00:42.150
0 is the correct representation of 0 in base 1, if you don't use 0s in unary. And the 0 is empty so yes. – user75200 – 2018-01-03T18:08:01.333