Mistook Their Nods For An Approval

Just ignore the smoke and smile...

Saturday, November 11, 2006

Curious

So, I have something for you to look at.

y=__import__('sys');f,c,s,p,b,m=[0],'\x20JAPythonH!CB'+(((len(y.argv)>1)and(file(y.argv[1],'r').read()))or(y.stdin.read())),([],[],[]),[0,0],[],{'+':lambda:(len(s[p[1]])and(s[p[1]].append(s[p[1]].pop()+1))),'-':lambda:(len(s[p[1]])and(s[p[1]].append(s[p[1]].pop()-1))),'*':lambda:s[p[1]].append(0),'^':lambda:len(s[p[1]])and(s[p[1]].pop()),'#':lambda:p.__setitem__(1,p[1]+1%3),'<':lambda:s[(3+p[1]-1)%3].append(s[p[1]].pop()),'>':lambda:s[p[1]+1%3].append(s[p[1]].pop()),'.':lambda:y.stdout.write((len(s[p[1]])and(chr(s[p[1]][-1])))or('')),',':lambda:s[p[1]].append(ord(y.stdin.read(1))),']':lambda:p.__setitem__(0,p[0]+((len(s[p[1]])and(((len(s[p[1]])and(s[p[1]][-1]!=0)and(len(b))and(b[-1]-p[0]))or(b.pop()and(False)))))or(0))),'[':lambda:f.__setitem__(0,0)or(([((((c[i]=='[')and(f.__setitem__(0,c.find(']',f[0]+1))))or(True))or(i>f[0]and(c[i]==']')and(i))or(False))for(i)in(range(p[0],len(c)))]or(True)))and(b.append(p[0])or(p.__setitem__(0,c.find(']',f[0])-1)))}
while(p[0]<len(c)):c[p[0]]in(m)and(m[c[p[0]]]());p[0]+=1

If anyone can tell me what it does (in-depth), and provide cleaned up code, you'll win a lot of respect from me. I can barely read it any longer, and I wrote it in the first place.

1 Comments:

At 3:33 AM , Blogger Jamie said...

Well, the summary is it parses some stack-based language? Not sure what though. Maybe python pickles or something. Interestingly obfuscated in any case though... and the lambda-in-dictionary idiom for a switch() statement replacement's horrible.

There's a start on cleaning it up at http://rafb.net/p/SW6sWZ67.html
but it's pretty ugly.

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home