Created
August 16, 2013 19:03
-
-
Save postylem/6252600 to your computer and use it in GitHub Desktop.
outputs a program that prints itself after n iterations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a clunky n-cycle (iterated quine) generator: | |
def quiner(n): | |
'''prints a program that will print itself after n iterations''' | |
quotes = '"'*3 | |
toprint = '' | |
for i in range(1,n): | |
toprint += 'def q' + str(i) + '(x):'""" | |
quotes = '"'*3 | |
print 'q""" + str(i+1) + "(' + quotes + x + quotes + ')'\n\n" | |
toprint += 'def q' + str(n) + '(x):'""" | |
quotes = '"'*3 | |
print x | |
print '' | |
print 'q1(' + quotes + x + quotes + ')'""" | |
print toprint + '\n\nq1(' + quotes + toprint + quotes + ')' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment