Created
February 11, 2012 19:07
-
-
Save pjlsergeant/1803656 to your computer and use it in GitHub Desktop.
Game of Life in 131 characters of Perl.
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
#!perl | |
use strict; | |
# Accepts a grid size, and a list representing the grid. 131 | |
# characters. RUNS UNDER STRICTURES BABY YEAH. | |
my$life=sub{$a=shift;map{$b=$_[$_];my$n;$n+=$_[$_]for($_-$a-1..$_-$a+1,$_-1,$_+1,$_+$a-1..$_+$a+1);$n+$b==3||$b&&$n==4||0}0..$#_}; | |
my $result = join '', $life->( 5, qw/ | |
1 0 0 0 0 | |
0 0 1 0 0 | |
0 1 0 1 0 | |
0 0 0 0 0 | |
0 0 0 0 0 | |
/); | |
print $result . "\n"; |
See this is an example of ruby being behind perl - https://gist.github.com/netmute/1761463 was only just pushed to ruby news channels ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I ran this code, my stereo fell off the table, almost killing my cat!