In this challenge you'll be building a program that grows as it traverses through the ages… Until it's 2017.
Challenge
Whenever this challenge description says “program”, you can also read “function”.
Your submission, when executed, will output a program that is THE LENGTH OF YOUR SUBMISSION + 1 bytes long.
When that program is executed, it will output a program that is THE LENGTH OF YOUR SUBMISSION + 2 bytes long… and so on.
However, when your program has reached a length of 2017 bytes, it must instead output 2017 and exit.
Rules
- The output of the final program has to be
2017and only2017. It can be a string or an integer, but it must read2017and not2017.0or0x7E1or other such nonsense. - No standard loopholes.
- Only your initial program is allowed to require input, which will be added to your bytecount.
So if your initial program is 324 characters long and takes an input of 13 bytes, your total score will be 324 + 13 = 337 and the program outputted by it must be 338 bytes long.- Using command line flags (e.g.
perl -X) is fine, however – as long as your initial program as well as all generated programs use the same flags. Also, they too count towards the total bytecount. Dashes, slashes etc. in front of a command line flag don't count towards the total, so e.g.perl -Xcounts as one additional byte.
- Using command line flags (e.g.
- If you return a function, it should be an actual function and not a string that, when evaluated, produces a function.
- Improper quines (if your program is a quine) are disallowed.
Example
Pseudocode, 99 bytes
IF (PROGRAM LENGTH == 2017) PRINT 2017 ELSE PRINT (THE SOURCE OF THIS PROGRAM + 1 BYTE PADDING)
Your submission may work differently, as long as it complies with the rules above.
;;;allowed? \$\endgroup\$