Heavily inspired by Hello, World! (Every other character)
Write a program that outputs 1
. When the first, third, fifth, etc. chars are removed, it outputs 2
. When all chars where their (1
-based) index in the source, mod N
, are not 0
, are removed, it should output N
.
This is code-challenge. The winner is the program that works with the largest N
, while working for all n < N
(obviously, to run up to N
, it has to be at least N
characters long). If there is a tie, the winner is the shortest answer that reaches the largest N
. Your program must at least work up to N=2
, since I don't think any languages will struggle with simply printing 1
. To prevent programs extending infinitely, your program may not be longer than 1024 bytes.
Example
Examples are based off of this sample program: abc123def456ghi789
.
For the program to work for N=1
, abc123def456ghi789
should output 1
.
For the program to work for N=2
, b13e46h79
should output 2
.
For the program to work for N=3
, c3f6i9
should output 3
.
For the program to work for N=4
, 1e67
should output 4
.
For the program to work for N=5
, 24i
should output 5
.
For the program to work for N=6
, 369
should output 6
.
For the program to work for N=7
, dh
should output 7
.
etc.
The highest N
this program could work for is its length, 18
.
Remember that the winner will be the question that works for the largest N
that also works for all smaller n
s where n<N
.
This is not a duplicate of Run the Nth characters to get N. That challenge take the first char and the each N
th char after that, while mine takes the N
th char and each N
th char after that. In addition, that is code-golf, and only is for N <= 16
N
.) \$\endgroup\$N
doesn't just turn this into an exercise in patience for who can be bothered to add the most numbers? I don't see any natural upper limit. \$\endgroup\$N
th char after that, while mine takes theN
th char and eachN
th char after that. In addition, that is code-golf, and only is forN <= 16
\$\endgroup\$