Given a positive integer nesting level n
and string s
of printable ascii characters( to
~
, output a program which, when run in the same language, outputs a program which outputs a program . . . which outputs the string s
.
A total of n
programs should be generated, all of which should be run in the same language as your answer.
Note: you may output programs or functions -- anything you are allowed by default as a submission.
You may input s
with escaped characters, how a program or function in your language would usually input a string.
Example
For example, given n=1
and s="recursion"
, a Python 2 program might output:
print "recursion"
Running this would output:
recursion
Given n=2
and s="PPCG", a Python 2 program might output:
print "print \"PPCG\" "
Running this outputs:
print "PPCG"
Running this outputs:
PPCG
Related (+title inspiration): One more LUL and I'm out
Also Related (in sandbox - now deleted, but can still be viewed with enough reputation): Source Code Recursion
Test Cases
Make sure that your code works for the following test cases (one per line):
n s
2 PPCG
4 Robert'); DROP TABLE Students;--
17 Deep
2 Spaces In Here
3 "Don't forget quotes!"
5 'Backt`cks might be a h`tch'
6 5%s
8 [Brackets]<Are>(Great){Usually}
3 !"#$%&'()*+,-./ 0123456789:;<=>?@ABCDEFGHIJKLMN
6 OPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
7 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
3 the quick brown fox jumps over the lazy dog
0
? \$\endgroup\$