adventofcode/06/1.pl
Yanick Champoux fdcd179eb0 day06
2017-12-06 11:50:31 -05:00

21 lines
386 B
Perl

use 5.20.0;
use experimental 'postderef';
#use List::SomeUtils qw/ min_by /;
use List::UtilsBy qw/ max_by/;
my @stacks = split ' ', <>;
my %seen;
until( $seen{ join ':', @stacks }++ ) {
warn "@stacks\n";
my $col = max_by { $stacks[$_] } 0..$#stacks;
my $v = $stacks[$col];
$stacks[$col] = 0;
$stacks[ ++$col % @stacks ]++ while $v--;
}
say scalar keys %seen;