Skip to main content
deleted 413 characters in body
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Python 2, 132 122 13870 bytes

Ørjan Johansen points out this didn't support escaped characters, so I've a comment to the end with the string after it.

def f(x='%r'x=''):x='%r'*(x!='%r'+'')+x;s="defs='def f(x=%r):x='%%r'*(x!='%%r'+%r)+x;s=%r;prints=%r;print s%%(x,x[2:],s,x[2:]x)#%s";print#%s';print s%(x,x[2:],s,x[2:]x)#

Try it online!Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds twoan extra %%ss after a comment, one in the check whether x has changed fromto output the default stringdata, and one to inserta x%r intoin the default string. The nice thing about this is that the code doesn't extend over multiple iterations. It always preserves its own structure and can return to push the original by passing instring as default instead of an empty string.

Python 2, 132 122 138 bytes

Ørjan Johansen points out this didn't support escaped characters, so I've a comment to the end with the string after it.

def f(x='%r'):x='%r'*(x!='%r'+'')+x;s="def f(x=%r):x='%%r'*(x!='%%r'+%r)+x;s=%r;print s%%(x,x[2:],s,x[2:])#%s";print s%(x,x[2:],s,x[2:])#

Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds two extra %s, one in the check whether x has changed from the default string, and one to insert x into the default string. The nice thing about this is that the code doesn't extend over multiple iterations. It always preserves its own structure and can return to the original by passing in an empty string.

Python 2, 70 bytes

def f(x=''):s='def f(x=%r):s=%r;print s%%(x,s,x)#%s';print s%(x,s,x)#

Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds an extra %s after a comment, to output the data, and a %r in the default string to push the original string as default instead of an empty string.

added support for escaped characters
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Python 2, 132 122 122138 bytes

Ørjan Johansen points out this didn't support escaped characters, so I've a comment to the end with the string after it.

def f(x='%r'):x='%r'*(x!='%r'+'')+x;s="def f(x=%r):x='%%r'*(x!='%%r'+%r)+x;s=%r;print s%%(x,x[2:],s,x[2:])";print#%s";print s%(x,x[2:],s,x[2:])#

Try it online!Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds two extra %s, one in the check whether x has changed from the default string, and one to insert x into the default string. The nice thing about this is that the code doesn't rely on comments, nor does it extend over multiple iterations. It always preserves its own structure and can return to the original by passing in an empty string.

Python 2, 132 122 bytes

def f(x='%r'):x='%r'*(x!='%r'+'')+x;s="def f(x=%r):x='%%r'*(x!='%%r'+%r)+x;s=%r;print s%%(x,x[2:],s)";print s%(x,x[2:],s)

Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds two extra %s, one in the check whether x has changed from the default string, and one to insert x into the default string. The nice thing about this is that the code doesn't rely on comments, nor does it extend over multiple iterations. It always preserves its own structure and can return to the original by passing in an empty string.

Python 2, 132 122 138 bytes

Ørjan Johansen points out this didn't support escaped characters, so I've a comment to the end with the string after it.

def f(x='%r'):x='%r'*(x!='%r'+'')+x;s="def f(x=%r):x='%%r'*(x!='%%r'+%r)+x;s=%r;print s%%(x,x[2:],s,x[2:])#%s";print s%(x,x[2:],s,x[2:])#

Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds two extra %s, one in the check whether x has changed from the default string, and one to insert x into the default string. The nice thing about this is that the code doesn't extend over multiple iterations. It always preserves its own structure and can return to the original by passing in an empty string.

-10 bytes
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Python 2, 135132 122 bytes

def f(x='%r'):
 s="defx='%r'*(x!='%r'+'')+x;s="def f(x=%r):\n s=%r\n if x='%%r'*(x!='%%r'+%r:x='%%r'+x\n print)+x;s=%r;print s%%(x,s,x[2:],s)"
 if x!='%r'+'':x='%r'+x
 print";print s%(x,s,x[2:],s)

Try it online!Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds two extra %s, one in the check whether x has changed from the default string, and one to insert x into the default string. The nice thing about this is that the code doesn't rely on comments, nor does it extend over multiple iterations. It always preserves its own structure and can return to the original by passing in an empty string.

Python 2, 135 bytes

def f(x='%r'):
 s="def f(x=%r):\n s=%r\n if x!='%%r'+%r:x='%%r'+x\n print s%%(x,s,x[2:])"
 if x!='%r'+'':x='%r'+x
 print s%(x,s,x[2:])

Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds two extra %s, one in the check whether x has changed from the default string, and one to insert x into the default string. The nice thing about this is that the code doesn't rely on comments, nor does it extend over multiple iterations. It always preserves its own structure and can return to the original by passing in an empty string.

Python 2, 132 122 bytes

def f(x='%r'):x='%r'*(x!='%r'+'')+x;s="def f(x=%r):x='%%r'*(x!='%%r'+%r)+x;s=%r;print s%%(x,x[2:],s)";print s%(x,x[2:],s)

Try it online!

A weird extension of the usual python quine s="s=%r;print s%%s";print s%s. This adds two extra %s, one in the check whether x has changed from the default string, and one to insert x into the default string. The nice thing about this is that the code doesn't rely on comments, nor does it extend over multiple iterations. It always preserves its own structure and can return to the original by passing in an empty string.

Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Loading