35
5
Challenge
Your task is to write a piece of code that outputs another piece of code. That code must in turn output yet another code until the final code outputs the integer 1. The chain ends the first time 1 is outputted.
None of your programs may share any characters (there's one exception in the Rules-section).
The winning submission will be the submission with the longest chain. The tie-breaker will be shortest total code-length.
Rules:
- You may use both functions, programs and snippets. You may assume a REPL environment.
- All functions must be written in the same language
- Symbol independent languages are disallowed. This includes partially symbol independent languages such as Headsecks.
- Default output formatting may optionally be disregarded in a function's output. This includes trailing newlines,
ans =
etc. - You may reuse the space character (ASCII code point 32), but note the following:
- You may use as many space characters as you like in one of the functions, but restrict it to maximum 5 in all other functions
- You may not reuse any characters if code point 32 is not space in your language.
None of the programs may take input
The chain must be at least two programs long.
Example:
Your initial code is abc+cab+bac
. This outputs: foofoo*123
, which in turn outputs disp(~0)
, which outputs 1
. This is a chain of 3 programs, with a combined length of 29 (tie breaker).
Related – Jo King – 2018-05-28T12:05:26.743
1Somewhat related – Kevin Cruijssen – 2018-05-28T12:07:54.693
To make sure I understood: the programs may use comments, right? I mean, parts of code that are "useless" – Luis Mendo – 2018-05-28T13:00:10.837
@LuisMendo Yes... I'm curious to see how that will help you though :) – Stewie Griffin – 2018-05-28T13:18:48.193
@StewieGriffin Not much really :-) It only makes code length arbitrarily large, but it doesn't seem to help in extending the number of chain links – Luis Mendo – 2018-05-28T13:27:22.130
If the language prints strings with quotation marks, can the next program just contain the string without the quotes, or does the next program always have to be literally the entire output of the previous one? – ngm – 2018-05-28T14:18:21.067
Is it ok if we cannot prove or disprove the chain will eventually output a 1? – R zu – 2018-05-28T17:21:10.497
@Rzu You must prove that it will output 1 in the end. – Stewie Griffin – 2018-05-28T18:10:09.917
@ngm quotes must be included. – Stewie Griffin – 2018-05-28T18:31:03.773
The output of each program should be a string (or equivilant), yes? For example,
lambda:lambda:1
isn't valid since it returns an function? – Jo King – 2018-05-28T23:42:45.5472Are simple expressions allowed? For example, could the final link of a Python program be
2^3
, which would just evaluate to1
, or does it have to be e.g.lambda:2^3
,print(2^3)
, etc.? – nneonneo – 2018-05-29T01:22:35.253If a function/snippet returns a string, are the string contents considered to be the code? The current top Java 8 answer uses this fact. – nneonneo – 2018-05-29T01:29:34.950
May the programs share boilerplate, such as
int main()
and the like? – ollien – 2018-05-29T01:40:28.4133In languages where literals can be programs (such as in a lot of the golfing langs), can
1
be both a program and the output of that program or does the chain end when1
is the output? – Emigna – 2018-05-29T07:26:06.153@nneonneo simple expressions are allowed. That's what is meant by allowing "snippets". Have a look at this answer to another challenge. Such answers are allowed.
– Stewie Griffin – 2018-05-29T10:39:12.217@Emigna the chain ends when
1
is the output. – Stewie Griffin – 2018-05-29T10:42:10.523@ollien stuff like this and this is valid. Does that answer the question?
– Stewie Griffin – 2018-05-29T10:45:13.577Exactly what output types are allowed for a language that has strings? Just strings, or would an array of bytes/chars/code points be allowed? – Jakob – 2018-05-30T18:28:31.217
@Jakob everything that can be copied and use as code directly. – Stewie Griffin – 2018-05-30T19:34:26.633
Probably because it's very very hard. Until someone comes along and posts one with 12 programs. :-) – Stewie Griffin – 2018-06-02T07:13:35.230
Are we allowed to count the output
1.0
as part of the chain, since you state "Default output formatting may optionally be disregarded in a function's output."? SoABC
->1.0
->1
(chain of 2)? (What if I don't want to disregard it to improve the amount of chains.) – Kevin Cruijssen – 2018-06-04T15:01:42.697That's what optionally means :-)
X -> 1.0 -> 1
may count as 2.X -> 1-> 1
counts as 1. Note that the final output should be1
, not1.0
. – Stewie Griffin – 2018-06-04T15:48:26.503