Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

willsheppard commented Sep 26, 2012

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

@fifitrixabelle

This comment has been minimized.

Copy link

fifitrixabelle commented Sep 11, 2013

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
You can’t perform that action at this time.