Last active
April 20, 2020 00:21
-
-
Save youchan/ff191eed286fab7929a730e61d999e95 to your computer and use it in GitHub Desktop.
One liner version n Conway's Game of Life
This file contains 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;Array.new((s+2)*(s+2),0).tap{|g|[100,133,163,164,165].each{|i|g[i]=1};100.times{s.times{|y|puts s.times.map{|x|g[x+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{|x|g[i+x%3+x/3*2+x/3*s]}.sum.then{|x|x==3?1:x==2?g[i+s+3]:0}}.tap{|n|(s*s).times{|i|g[i+s+3+i/s*2]=n[i]}};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