adventofcode/2018/01/sol2.pl

17 lines
235 B
Perl
Raw Normal View History

2018-12-01 14:32:12 +00:00
use List::AllUtils qw/ sum first /;
use 5.20.0;
my @nums = <>;
my $index = 0;
my %seen;
my $current = 0;
while() {
$current += $nums[ $index++ % @nums ];
say $current and last if $seen{$current};
$seen{$current}++;
}