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";
it/ui.c?h=enroll&id=b36a1347022965fdbe1b61298dc6a05be2d2a34d&follow=1'>Use formatParse split to position input cursorJune McEnroe 2018-09-12Factor out IRC formatting parsingJune McEnroe 2018-09-11Add /help equivalent to /manJune McEnroe 2018-09-11Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe