Game of Life in One Line of MATLAB

Conway’s game of life in one tweet of MATLAB:

s=[1 1 1]';n=@(a)conv2(s,s',1*a,'same')-a;lf=@(a)n(a)==2&a|n(a)==3;a=rand(128)>0.8;for ii=1:500,spy(a);drawnow;a=lf(a);end

via Twitter / Matthew McDonnell.

Advertisements