22
3
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
01for1. - 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+1has no surrounding quotation marks.N , Code_for_N+1is 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=2can be:2, printer 2. In this case,printer 2is the code forN=3. You can't use the entire output:2, printer 2as 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=15then it must either printSTOP!(see bonus), or don't print anything at all (not even a space or newline).- The code for
N=15can not crash (but outputting to STDERR is OK). - You are disqualified if the output code for
N=15prints16or 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!
So, say,
f=>f+""would be invalid? (f+""returns the function's construction code.) – Conor O'Brien – 2016-01-07T17:23:21.437@CᴏɴᴏʀO'Bʀɪᴇɴ without it, is it even possible to achieve the task... – nicael – 2016-01-07T17:27:58.770
@nicael It's been done already, at least in the js answer – Conor O'Brien – 2016-01-07T17:29:25.720
1@CᴏɴᴏʀO'Bʀɪᴇɴ ...in a viable way :D – nicael – 2016-01-07T17:31:07.080
The rules are confusing, can I output something like
14, print(14+1)or not? – nyuszika7h – 2016-01-09T15:48:20.443@nyuszika7h yes you can. – Stewie Griffin – 2016-01-09T19:43:59.017