Last active
November 8, 2024 05:04
-
-
Save youchan/ff191eed286fab7929a730e61d999e95 to your computer and use it in GitHub Desktop.
One liner version n Conway's Game of Life
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s=30;g=[0]*(s+2)**2;[100,133,163,164,165].each{g[_1]=1};100.times{s.times{|y|puts s.times.map{g[_1+s+3+y*(s+2)]==1??*:?.}.join};(s*s).times.map{|i| i+=i/s*2;[0,1,2,3,5,6,7,8].map{g[i+_1%3+_1/3*2+_1/3*s]}.sum.then{_1==3?1:_1==2?g[i+s+3]:0}}.tap{|n|(s*s).times{g[_1+s+3+_1/s*2]=n[_1]}};sleep(0.1);print"\e[#{s}A"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment