-
Notifications
You must be signed in to change notification settings - Fork 0
/
malbolge.py
2 lines (2 loc) · 1.33 KB
/
malbolge.py
1
2
mal = lambda code: [(crz := lambda a, b: sum([[[1,0,0],[1,0,2],[2,2,1]][db][da] for da, db in zip([a//(3**(9-x))%3 for x in range(10)], [b//(3**(9-x))%3 for x in range(10)])][x]*(3**(9-x)) for x in range(10))), (memory := [ord(x) for x in code]), (memory.append(crz(memory[-1], memory[-2])) for x in range(3**10-len(code))), (c := [0]), (a := [0]), (d := [0]),(running := [True]),list(iter(lambda: [None if 33 <= memory[c[0]] <= 126 else exit(),{4: lambda: c.__setitem__(0, memory[d[0]]),5: lambda: print(end=chr(a[0]%256)),23: lambda: a.__setitem__(0, ord(input()[0])),39: lambda: [memory.__setitem__(d[0], (new:=(lambda i: i//3+(i%3)*(3**9))(memory[d[0]], ))), a.__setitem__(0, new)],40: lambda: d.__setitem__(0, memory[d[0]]),62: lambda: [memory.__setitem__(d[0], (new:=crz(a[0],memory[d[0]]))), a.__setitem__(0, new)],81: lambda: running.__setitem__(0, False)}.get((memory[c[0]]+c[0])%94, lambda: None)(),memory.__setitem__(c[0], b"9m<.TVac`uY*MK'X~xDl}REokN:#?G\"i@5z]&gqtyfr$(we4{WP)H-Zn,[%\\3dL+Q;>U!pJS72FhOA1CB6v^=I_0/8|jsb"[memory[c[0]]%94]) if 33 <= memory[c[0]] <= 126 else None, c.__setitem__(0, (c[0]+1)%(3**10)), d.__setitem__(0, (d[0]+1)%(3**10)), running[0]][-1], False))]# TODO: better input method according to spec; TODO: invalid char filtering
mal('''(=<`#9]~6ZY327Uv4-QsqpMn&+Ij"'E%e{Ab~w=_:]Kw%o44Uqp0/Q?xNvL:`H%c#DD2^WV>gY;dts76qKJImZkj''')