Skip to main content
added 93 characters in body
Source Link
jazzpi
  • 886
  • 5
  • 9

Python 3, 181 175 171171 162

a=0
s=lambda x:"a=%d"%(x!=-1and x!=256and x)
while 1:
 print(">>")
 for i in input(">>"):u,b,o=s(a+1),s(a*a),"print(a)";exec(dict(i=u,x=u,d=s(a-1),s=b,k=b,o=o,c=o).get(i,""))

This outputs a newline after theThis outputs a newline after the >>, but the OP didn't say that wasn't allowed. Not anymore!

Thanks to >>GlitchMr, but the OP didn't say that wasn't allowed.minitech and golfer9338!

Python 3, 181 175 171

a=0
s=lambda x:"a=%d"%(x!=-1and x!=256and x)
while 1:
 print(">>")
 for i in input():u,b,o=s(a+1),s(a*a),"print(a)";exec(dict(i=u,x=u,d=s(a-1),s=b,k=b,o=o,c=o).get(i,""))

This outputs a newline after the >>, but the OP didn't say that wasn't allowed.

Python 3, 181 175 171 162

a=0
s=lambda x:"a=%d"%(x!=-1and x!=256and x)
while 1:
 for i in input(">>"):u,b,o=s(a+1),s(a*a),"print(a)";exec(dict(i=u,x=u,d=s(a-1),s=b,k=b,o=o,c=o).get(i,""))

This outputs a newline after the >>, but the OP didn't say that wasn't allowed. Not anymore!

Thanks to GlitchMr, minitech and golfer9338!

Didn't even see that comment
Source Link
jazzpi
  • 886
  • 5
  • 9

Python 3, 181 175175 171

a=0
s=lambda x:["a="+str"a=%d"%(x),"a=0"][x in(!=-1,2561and x!=256and x)]
while 1:
 print(">>")
 for i in input():u,b,o=s(a+1),s(a*a),"print(a)";exec(dict(i=u,x=u,d=s(a-1),s=b,k=b,o=o,c=o).get(i,""))

This outputs a newline after the >>, but the OP didn't say that wasn't allowed.

Python 3, 181 175

a=0
s=lambda x:["a="+str(x),"a=0"][x in(-1,256)]
while 1:
 print(">>")
 for i in input():u,b,o=s(a+1),s(a*a),"print(a)";exec(dict(i=u,x=u,d=s(a-1),s=b,k=b,o=o,c=o).get(i,""))

This outputs a newline after the >>, but the OP didn't say that wasn't allowed.

Python 3, 181 175 171

a=0
s=lambda x:"a=%d"%(x!=-1and x!=256and x)
while 1:
 print(">>")
 for i in input():u,b,o=s(a+1),s(a*a),"print(a)";exec(dict(i=u,x=u,d=s(a-1),s=b,k=b,o=o,c=o).get(i,""))

This outputs a newline after the >>, but the OP didn't say that wasn't allowed.

Saved 6 characters
Source Link
jazzpi
  • 886
  • 5
  • 9

Python 3, 181181 175

a=0
defs=lambda s(x):return["a="+str["a="+str(x),"a=0"][x==-1or"a=0"][x x==256]in(-1,256)]
while 1:
 print(">>")
 for i in input():u,b,o=s(a+1),s(a*a),"print(a)";exec(dict(i=u,x=u,d=s(a-1),s=b,k=b,o=o,c=o).get(i,""))

This outputs a newline after the >>, but the OP didn't say that wasn't allowed.

Python 3, 181

a=0
def s(x):return["a="+str(x),"a=0"][x==-1or x==256]
while 1:
 print(">>")
 for i in input():u,b,o=s(a+1),s(a*a),"print(a)";exec(dict(i=u,x=u,d=s(a-1),s=b,k=b,o=o,c=o).get(i,""))

This outputs a newline after the >>, but the OP didn't say that wasn't allowed.

Python 3, 181 175

a=0
s=lambda x:["a="+str(x),"a=0"][x in(-1,256)]
while 1:
 print(">>")
 for i in input():u,b,o=s(a+1),s(a*a),"print(a)";exec(dict(i=u,x=u,d=s(a-1),s=b,k=b,o=o,c=o).get(i,""))

This outputs a newline after the >>, but the OP didn't say that wasn't allowed.

Source Link
jazzpi
  • 886
  • 5
  • 9
Loading