Challenge
Write \$2 \le n \le 10\$ distinct, valid non-halting full programs in your language of choice. If all of them are concatenated in order, the resulting full program should be a valid halting program, but if any of them are left out, the result should still be a valid non-halting program.
More formally, write \$2 \le n \le 10\$ distinct programs \$P_1, P_2, \cdots, P_n\$ in a language \$L\$ of your choice, which satisfy the following property:
- \$P_1 P_2 \cdots P_n\$ (where \$XY\$ means string concatenation of two programs \$X\$ and \$Y\$) is valid full program in \$L\$ and, given no input, halts in finite time.
- If you delete any of \$1 \le x \le n-1 \$ program segments (\$P_i\$'s where \$1 \le i \le n\$) from the above, the result is still a valid full program in \$L\$, but does not halt in finite time.
- In other words, any nonempty proper subsequence of \$P_1 P_2 \cdots P_n\$ should be a valid non-terminating program in \$L\$.
A program is valid if a compiler can successfully produce an executable or an interpreter finishes any pre-execution check (syntax parser, type checker, and any others if present) without error. A valid program is halting if the execution finishes for any reason, including normally (end of program, halt command) or abnormally (any kind of runtime error, including out-of-memory and stack overflow). The output produced by any of the programs does not matter in this challenge.
For example, a three-segment submission foo
, bar
, and baz
is valid if
foobarbaz
halts in finite time, and- each of
foo
,bar
,baz
,foobar
,foobaz
, andbarbaz
does not halt in finite time in the same language. (The behavior ofbarfoo
orbazbar
does not matter, since the segments are not in order.)
The score of your submission is the number \$n\$ (the number of program segments). The higher score wins, tiebreaker being code golf (lower number of bytes wins for the same score). It is encouraged to find a general solution that works beyond \$n = 10\$, and to find a solution that does not read its own source code (though it is allowed).
P1 + ... + P(n-1)
diverges then the concatenation of that withP(n)
necessarily also diverges. \$\endgroup\$