Skip to content

Instantly share code, notes, and snippets.

@elteammate
Created August 5, 2022 09:41
Show Gist options
  • Save elteammate/59094c74a90581b91ea2a04c6d44ddf3 to your computer and use it in GitHub Desktop.
Save elteammate/59094c74a90581b91ea2a04c6d44ddf3 to your computer and use it in GitHub Desktop.
Zenf*ck
zen = """Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!""".splitlines()
import random
random.seed(1337)
in_ = "-[----->+<]>+.--."
out = "\n".join([zen[("><+-[].".find(c) + random.randrange(0, len(zen))) % len(zen)] for i, c in enumerate(in_)])
print(out)
import sys;from random import*;seed(1337);q=sys.stdout;n=lambda *x:None;sys.stdout=type("",(object,),{"write":n,"flush":n})();from this import*;sys.stdout=q;l="".join([d.get(c, c)for c in s]).splitlines()[2:];g=4**5;G=[chr(g+_)for _ in range(len(l))];t=0;u=globals().update;f=lambda p:[u(t=p),"".join(map(lambda x:str(u(t=t.replace(x[0][:-1],x[1]))),zip(l,G))),u(t="".join(filter((lambda Y:Y in G),t))),list(map(lambda _:(ord(_)-g-randrange(len(l)))%len(l),t))][-1];L=[0];P=0;I=0;T=0;B=0;F=0;S=0;O=0;U=0;run=lambda p:[u(U=f(p),T=[0]*5**5,P=0,I=0,O="",B={},S=[],F=[0]),[([B.update({Q:i,i:Q})for Q in[S.pop()for _ in L if c==5]],[S.append(i)for _ in L if c==4])for i,c in enumerate(U)],[[[u(P=P+1) for _ in L if U[I]==0],[u(P=P-1) for _ in L if U[I]==1],[T.__setitem__(P,(T[P]+1)%256)for _ in L if U[I]==2],[T.__setitem__(P,(T[P]-1)%256)for _ in L if U[I]==3],[u(I=B[I])for _ in L if(U[I]==4and T[P]==0 or U[I]==5and T[P]!=0)],[u(O=O+chr(T[P]))for _ in L if U[I]==6],[F.append(u(I=I+1))for _ in L if I+1<len(U)]]for W in F],O][-1]
print(run("""
Explicit is better than implicit.
Although never is often better than *right* now.
Simple is better than complex.
Simple is better than complex.
Although practicality beats purity.
Although that way may not be obvious at first unless you're Dutch.
Although never is often better than *right* now.
In the face of ambiguity, refuse the temptation to guess.
In the face of ambiguity, refuse the temptation to guess.
Although that way may not be obvious at first unless you're Dutch.
In the face of ambiguity, refuse the temptation to guess.
In the face of ambiguity, refuse the temptation to guess.
Sparse is better than dense.
Beautiful is better than ugly.
Although never is often better than *right* now.
Sparse is better than dense.
Complex is better than complicated.
"""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment