adventofcode/2020/03/part1.pl

25 lines
299 B
Perl
Raw Normal View History

2021-12-05 16:51:21 +00:00
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;