adventofcode/2020/03/part1.pl
2021-12-05 11:51:21 -05:00

25 lines
299 B
Perl

use 5.20.0;
use warnings;
use experimental qw/
signatures
postderef
/;
use Path::Tiny;
my @forest = path(shift)->lines({chomp => 1 });
my $trees = 0;
my $i = 0;
for my $line ( @forest ) {
$trees++ if '#' eq substr $line, $i, 1;
$i+=3;
$i %= length $line;
}
print $trees;