Skip to content

Instantly share code, notes, and snippets.

@mlliarm
Created April 15, 2022 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlliarm/a57e3799ec92d46221cdef2240b3bf2a to your computer and use it in GitHub Desktop.
Save mlliarm/a57e3799ec92d46221cdef2240b3bf2a to your computer and use it in GitHub Desktop.
Obfuscated python for the Game of Life
# Credit to `oskar31415` from the r/APLjk discord server for sharing the code and his friend for writing it.
'''
Original code:
(lambda N,P:(lambda f,i:P.show(__import__('matplotlib.animation',fromlist=['FuncAnimation']).FuncAnimation(f,lambda i:[i.set_array((lambda g:(lambda n:N.logical_or(n==3,N.logical_and(g,n==2)))((N.sum([N.roll(N.roll(g,y,1),x,0)for x in(-1,0,1)for y in(-1,0,1)if x|y],0))))(i.get_array())),[i]][1],interval=0,blit=1)))(P.figure(),P.imshow(N.random.rand(200,400)<.2,)))(__import__("numpy"),__import__("matplotlib.pyplot")) 
'''
# Expanded by mlliarm@
import pdb
try:
import matplotlib.pyplot as P
import numpy as N
(lambda N,P:(lambda f,i:P.show(
__import__('matplotlib.animation',fromlist=['FuncAnimation']).FuncAnimation(
f,lambda i:[i.set_array(
(lambda g:(
lambda n:N.logical_or(
n==3,N.logical_and(g,n==2)
)
)(
(N.sum(
[N.roll(N.roll(g,y,1),x,0)for x in(-1,0,1)for y in(-1,0,1)if x|y],0
))
))(i.get_array())
),[i]][1],
interval=0,blit=1)
))(P.figure(),P.imshow(
N.random.rand(200,400)<.2,
)))#(__import__("numpy"),__import__("matplotlib.pyplot"))
print('works?')
except Exception:
pdb.post_mortem()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment