A program ordinal is a (possibly transfinite) ordinal which can be assigned to programs in some language depending on their output.
To be more specific:
- Strings that give no output have ordinal 0
- Programs that output a program of ordinal n have ordinal n+1
- Programs P0 outputting multiple programs P1, P2... Pn have ordinal S, where S is the supremum of the set of program ordinals corresponding to the programs P1, P2... Pn
Your goal is to create the shortest possible program with program ordinal ω*ω, also writable as ω2 or omega squared.
Output is required for a program. As well as this, the output must go through STDOUT or closest equivalent.
All programs printed by your program must be delimited by any string, so long as the delimiter is always the same. (acbcd
and accbccd
are allowed, but not acbed
) These delimiters must be the only output other than the programs themselves, unless your language must output trailing characters.
Here is a program-ordinal ω program created in pseudocode, which generates programs of the form "exit, print(exit), print("print(exit)")...:
x=exit
loop{
print(x)
x='print(#x)'
}
Within each iteration of the loop, x is printed and then wrapped in print() (exit becomes print(exit)). # is put before x in pseudocode to indicate that it is the variable x and not the actual alphabetical character x.
The shortest program (measured in bytes) which has program ordinal ω2 wins. Have fun.
0
be replaced by a program that prints nothing (for example,exit
orprint ""
)? What your example prints first is the number0
, which isn't a program (at least in most languages). \$\endgroup\$ – Mitchell Spector May 27 '20 at 5:50x="print(x)"
is meant to havex
be replaced with its value within the string? \$\endgroup\$ – xnor May 27 '20 at 5:55