Last active
November 4, 2022 08:07
-
-
Save Radagaisus/856bb43e4352160eed6d7f69fe5cf28e to your computer and use it in GitHub Desktop.
Self-Modifying Quine
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
def f(x,s): | |
start = 44 | |
a = 0 | |
print(a) | |
if x==1: | |
start = int(s[24:29]) | |
s = list(s[:24]) + list('{:>5d}'.format(start+11)) + list(s[29:start]) + list(' a += 1\n') + list(s[start:]) | |
s = ''.join(s) | |
return s | |
s = "def f(x,s):\n"\ | |
" start = 44\n"\ | |
" a = 0\n"\ | |
" print(a)\n"\ | |
" if x==1:\n"\ | |
" start = int(s[24:29])\n"\ | |
" s = list(s[:24]) + list('{:>5d}'.format(start+11)) + list(s[29:start]) + list(' a += 1\\n') + list(s[start:])\n"\ | |
" s = ''.join(s)\n"\ | |
" return s" | |
for x in [1,1,1,1,1,1,1,1,1]: | |
s = f(x,s) | |
print(s) | |
exec(s) |
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
def f(x,s): | |
a = 0 | |
print(a) | |
if x==1: | |
s = list(s) | |
s[20:25] = list('{:>5d}'.format(int(''.join(s[20:25]))+1)) | |
s = ''.join(s) | |
return s | |
s = 'def f(x,s):\n'\ | |
' a = 0\n'\ | |
' print(a)\n'\ | |
' if x==1:\n'\ | |
' s = list(s)\n'\ | |
" s[20:25] = list('{:>5d}'.format(int(''.join(s[20:25]))+1))\n"\ | |
" s = ''.join(s)\n"\ | |
" return s\n" | |
for x in [1,1,0,0]: | |
s = f(x,s) | |
print(s) | |
exec(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment