Skip to content

Instantly share code, notes, and snippets.

@pjlsergeant
Created February 11, 2012 19:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjlsergeant/1803656 to your computer and use it in GitHub Desktop.
Save pjlsergeant/1803656 to your computer and use it in GitHub Desktop.
Game of Life in 131 characters of Perl.
#!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";
@willsheppard
Copy link

When I ran this code, my stereo fell off the table, almost killing my cat!

@fifitrixabelle
Copy link

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