Turtlèd, Python 2, and Python 3, 3 languages, only competing for bounty
all oneliners follwed by newline
Turtlèd
@##'@r,r,r-{ +.r_}r{ +.r_}!!-.(3"';m=ord(input()[-1]);_='x=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))';print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"367>;++[ d( d)('.)]d<"x='"))(2"';m=ord(raw_input()[-1]);_='x=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))';print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"371>;++[ d( d)('.)]d<"x='"))(d' )#'@r,r,r-{ +.r_}r{ +.r_}!!-.(3"';m=ord(input()[-1]);_='x=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))';print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"367>;++[ d( d)('.)]d<"x='"))(2"';m=ord(raw_input()[-1]);_='x=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))';print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"371>;++[ d( d)('.)]d<"x='"))(d' )
Try it online!
Python 2
x='@##y@r,r,r-{ +.r_}r{ +.r_}!!-.(3"y;m=ord(input()[-1]);_=yx=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))y;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"367>;++[ d( d)(y.)]d<"x=y"))(2"y;m=ord(raw_input()[-1]);_=yx=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))y;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"371>;++[ d( d)(y.)]d<"x=y"))(dy )#y@r,r,r-{ +.r_}r{ +.r_}!!-.(3"y;m=ord(input()[-1]);_=yx=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))y;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"367>;++[ d( d)(y.)]d<"x=y"))(2"y;m=ord(raw_input()[-1]);_=yx=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))y;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"371>;++[ d( d)(y.)]d<"x=y"))(dy )';m=ord(raw_input()[-1]);_='x=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))';print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))
Try it online!
Python 3
x='@##y@r,r,r-{ +.r_}r{ +.r_}!!-.(3"y;m=ord(input()[-1]);_=yx=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))y;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"367>;++[ d( d)(y.)]d<"x=y"))(2"y;m=ord(raw_input()[-1]);_=yx=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))y;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"371>;++[ d( d)(y.)]d<"x=y"))(dy )#y@r,r,r-{ +.r_}r{ +.r_}!!-.(3"y;m=ord(input()[-1]);_=yx=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))y;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"367>;++[ d( d)(y.)]d<"x=y"))(2"y;m=ord(raw_input()[-1]);_=yx=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))y;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))"371>;++[ d( d)(y.)]d<"x=y"))(dy )';m=ord(input()[-1]);_='x=%r;m=ord(input()[-1]);_=%r;print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%%(x,_) if m==50 else _%%(x,_) if m==51 else x.replace(chr(121),chr(39)))';print(_.replace(chr(100)+chr(40),chr(100)+chr(40)+chr(114)+chr(97)+chr(119)+chr(95))%(x,_) if m==50 else _%(x,_) if m==51 else x.replace(chr(121),chr(39)))
Try it online!
Explanation:
For each language, I took already written quines and modified them a bit.
Turtlèd first:
Turtlèd includes the standard quine structure. however, should the input end with a 2 or a 3, it appends the end of the python code, either 2 or 3, it includes them both separately, to the quine output, and then goes back to the start and adds x='
. Otherwise the sourcecode is left and output like a regular quine
Also note it takes input twice !!.
, because the source contains a newline which feeds to input an empty line.
however, along the way to the start of string, in order to avoid the fact that the string cannot have '
in it, it changes all the '
in the main source along the way to y
. if it did, quote escaping could be annoying, if even possible
this relies on a trick; I could not have written (''y)
, (pseudocode:if cell is ', write y)
, because then that y would have been indistinguishable from a '. so, I use the y from the input "Python"! this was a real eureka moment for me.
then, there are the python quinelike things.
How the python quinelike thing works:
it works like a regular quine, except it also includes the variable x
if it has input Python 3, it works like a regular quine, and uses % formatting to also include the source for Turtlèd.
if it has input Python 2, it replaces input
in the string with raw_input
, and does otherwise the exact same thing.
if input is Turtlèd, it replaces the y
s in the Turtlèd source and prints it.
The two python programs function the same, and take input the same way