8
1
Challenge
Write the shortest program P such that
- P takes any positive integer n as input, and outputs a program string P1
executing P1 (with no input) outputs a program string P2,
executing P2 (with no input) outputs a program string P3,
...
- executing Pn (with no input) outputs exactly "Hello!" (without the quotes).
Schematically:
P(n) → P1 → P2 → ... → Pn → Hello!
Criteria
- I/O is via stdin/stdout.
- Program length is measured in bytes.
- Programs consist only of ASCII printable characters.
- There must be no duplicates among the programs P, P1,...,Pn.
EDIT: Programs P, P1,...,Pn are meant to be source code, and "executing the program" refers to whatever processing produces the output (i.e., interpretation, compilation & execution, etc.).
1
Related: http://codegolf.stackexchange.com/questions/5510/can-you-meta-quine
– dmckee --- ex-moderator kitten – 2012-07-06T20:03:39.257@dmckee - The relationship, if any, seems very remote. Schematically, a quine's behavior is like P-->P, and the linked programs' behavior is like P-->Q-->P; but here the behavior is like P(n)-->...-->Hello!, where P is not required to resemble any of the outputs. – r.e.s. – 2012-07-07T00:12:07.960
1That's not a criticism, r.e.s., just a note that people who like this problem might like the other one as well. – dmckee --- ex-moderator kitten – 2012-07-07T00:21:41.817
@dmckee - Good point, thanks. – r.e.s. – 2012-07-07T00:31:04.097