This question already has an answer here:
s of printable ASCII characters, newlines, and spaces (
0x20 ( ) to
0x7E (~)), and a non-negative integer
To write a program that outputs either another program, or
s depending on
n = 1, Then your code should output code which outputs
n = 2, Your code should output code which outputs code which outputs
s and so on.
All outputted code should be in the same language as the language of the original submission.
s, n -> output
No cycles, 0 -> No cycles Hello, 1 -> console.log("Hello"); Cycle!, 3 -> console.log("console.log(\"console.log(\\\"Cycle!\\\")\")"); :), 3 -> console.log("console.log('console.log(`:)`)')");
This is code-golf, so aim for shortest code in bytes.
- I/O format is flexible
- Default rules and standard loopholes apply.
- The output of your submission must be valid.
- You can use any language, even if it was created after this challenge, as long as it wasn't created for the purpose of this challenge
- Input is guaranteed to be valid as defined in the
Here's a quick tip to test your answers:
s are inputs