Making a versatile integer printer is nice and all, but writing a single code that prints a lot of different numbers is cumbersome. Wouldn't it be easier to make a script that outputs a number, but also gives you a new script to get the next number?
Challenge:
Write a code that outputs a single integer N
and an executable code. The next code should output N+1
and a code that can output N+2
. Continue this path until you reach N = 15
. (The last printed number should be 15).
Rules:
- No input (assume the input is empty).
- Full program or function or other convenient formats are allowed.
- The first code should output
1
. - You can't output leading zeros. I.e. you can't print
01
for1
. - The output must be on the format
N, Code_for_N+1
. Note that the output is separated by a comma and a single space. The code forN+1
has no surrounding quotation marks.N , Code_for_N+1
is not accepted (space in front of the comma). Trailing newlines are OK. - The first character(s) of the output must be the number. (No leading spaces, or
ans = N
). - The printed number should not be part of the next code (the code can contain this number, but you can't take the output number as part of the code)
- Example: The output for
N=2
can be:2, printer 2
. In this case,printer 2
is the code forN=3
. You can't use the entire output:2, printer 2
as code forN=3
.
- Example: The output for
- The scripts may be in different languages
- The datatypes are irrelevant (the number can be a string), but it can't be surrounded by anything (quotation marks, parentheses etc).
- If there is a code outputted for
N=15
then it must either printSTOP!
(see bonus), or don't print anything at all (not even a space or newline).- The code for
N=15
can not crash (but outputting to STDERR is OK). - You are disqualified if the output code for
N=15
prints16
or anything else (except the bonus case).
- The code for
- Built in quine operators are not allowed.
- Accessing the source file through the file system is not allowed.
Bonus:
-10 bytes if the code that prints 15 also produces a code that prints "STOP!
"
Examples using Python syntax: (obviously, these will only work for the selected integers, not from 1 to 15.)
N = 1
print "1, print 2"
1, print 2
---
N = 15
print 15
15
---
N = 15 (Qualifies for the -10 bytes bonus)
print "15, print 'STOP!'"
15, print 'STOP!'
print 'STOP!'
STOP!
----
N = 15 (Qualifies for the -10 bytes bonus)
print "15, disp('STOP!')"
15, disp('STOP!') (disp('STOP!') outputs STOP! in MATLAB)
----
N = 15 (This one is not OK. The submission is disqualified)
print "15, print 16"
15, print 16
Standard golfing rules apply! Smallest code (for N=1) in bytes win!
f=>f+""
would be invalid? (f+""
returns the function's construction code.) \$\endgroup\$14, print(14+1)
or not? \$\endgroup\$