diff options
-rw-r--r-- | 2021/day06.pl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/2021/day06.pl b/2021/day06.pl new file mode 100644 index 0000000..b296a4c --- /dev/null +++ b/2021/day06.pl @@ -0,0 +1,16 @@ +use strict; +use warnings; +my @fish = split(/,/, <>); +for (1..80) { + my @spawns; + for my $f (@fish) { + if ($f) { + $f--; + } else { + $f = 6; + push @spawns, 8; + } + } + push @fish, @spawns; +} +print scalar(@fish), "\n"; |