19
1
Write the shortest program possible such that when you combine the first character and every Nth character after it into a new program, the output is N. This must work for N = 1, 2, ..., 16.
Another way to say it is, if you remove all the characters from your program except for the first one and every Nth one after that, the output of the remaining code should be N.
Example
If your code was
ABCDEFGHIJKLMNOP
N = 1 results in ABCDEFGHIJKLMNOP
. Running this should output 1.
N = 2 results in ACEGIKMO
. Running this should output 2.
N = 3 results in ADGJMP
. Running this should output 3.
N = 4 results in AEIM
. Running this should output 4.
N = 5 results in AFKP
. Running this should output 5.
N = 6 results in AGM
. Running this should output 6.
N = 7 results in AHO
. Running this should output 7.
N = 8 results in AI
. Running this should output 8.
N = 9 results in AJ
. Running this should output 9.
N = 10 results in AK
. Running this should output 10.
N = 11 results in AL
. Running this should output 11.
N = 12 results in AM
. Running this should output 12.
N = 13 results in AN
. Running this should output 13.
N = 14 results in AO
. Running this should output 14.
N = 15 results in AP
. Running this should output 15.
N = 16 results in A
. Running this should output 16.
Details
- All characters are allowed, ASCII and non-ASCII. (Newlines and unprintable ASCII are allowed as well. Note that carriage return and line feed count as distinct characters.)
- Your score is the length in characters of your unaltered program (15 in example). The lowest score wins.
- A score below 16 is clearly impossible because then at least two of the altered programs would be identical.
- Output may be to a file or stdout or anything else reasonable. However, the output of the 16 different programs must all go to the same place (e.g. it's not ok if
AO
goes to stdout butA
goes to a file). There is no input. - The output must be in decimal, not hex. The actual output should only contain the 1 or 2 characters that make up the number from 1 to 16, nothing else. (Things like Matlab's
ans =
are ok.) - Your program does not have to work for N = 17 or above.
Your stance on comments in the program? Yay or nay? – AndoDaan – 2014-08-19T03:41:18.787
1@AndoDaan Yay . – Calvin's Hobbies – 2014-08-19T03:47:43.717
Welcome back! =) I had to stare a while before realizing that this was indeed asked, not edited by Calvin Hobbies. – Vectorized – 2014-08-19T03:48:44.013
2Yay, so you didn't leave us after all! :D – Doorknob – 2014-08-19T04:02:22.280
What about newlines, are those treated as characters? Also, what about outputting unprintable characters to STDOUT additionally to the numbers? – overactor – 2014-08-19T04:50:11.213
3It looks like when code is
ABCDEFGHIJKLMNO
andN = 15
, result code is justA
. – Snack – 2014-08-19T04:54:56.487@githubphagocyte and Snack Fixed the examples and unclear parts. Thanks! – Calvin's Hobbies – 2014-08-19T14:24:30.500
@overactor Newlines are fine. Additional output is not. – Calvin's Hobbies – 2014-08-19T14:24:58.723
The specification leaves output undefined when input does not correspond to an N, is this correct? – Taemyr – 2014-08-20T09:20:08.467
@Taemyr Yes, that's right – Calvin's Hobbies – 2014-08-20T12:22:13.873