summary refs log tree commit diff homepage
path: root/2021/day06.pl
blob: 6e5fa15c3f5b690e24ece4d34de747aad0f0a1ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use strict;
use warnings;
my @init = split(/,/, <>);
my @fish = @init;
for (1..80) {
	my @spawns;
	for (@fish) {
		if ($_) {
			$_--;
		} else {
			$_ = 6;
			push @spawns, 8;
		}
	}
	push @fish, @spawns;
}
print scalar(@fish), "\n";
my %counts;
$counts{$_}++ for @init;
for (1..256) {
	my $zeros = $counts{0} // 0;
	$counts{$_} = $counts{$_+1} for 0..7;
	$counts{8} = $zeros;
	$counts{6} += $zeros;
}
my $sum = 0;
$sum += $_ for values %counts;
print "$sum\n";
e 2018-03-31Add hex output to schemeJune McEnroe 2018-03-31Add color scheme PNG generatorJune McEnroe 2018-03-31Simplify gfxx palette generationJune McEnroe 2018-03-31Switch to HSV for gfxx palette generationJune McEnroe 2018-03-30Generate default palette in gfxxJune McEnroe 2018-03-30Ignore build and cloneJune McEnroe 2018-03-30Set g:clipboard to pb{copy,paste} alwaysJune McEnroe Previously neovim would use these automatically if it found them, but now it only checks for them on macOS. pbd continues to work well. 2018-03-28Add d-_-b crateJune McEnroe