summaryrefslogtreecommitdiffstats
path: root/2020/day3/toboggan.pl
blob: d424a83ff4e3fea123e666236d548e73f3710e66 (plain)
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
29
30
use strict;
use warnings;
# use Smart::Comments;

open my $fh, '<', "input" or die "no input present, $!";

my $right_m = 3;
my $toboggan = 0;

my $trees = 0;

while (my $line = <$fh>) {
    chomp $line;

    ### $line
    my $curr = substr($line, $toboggan, 1);
    ### $curr

    if ($curr eq "#") {
        $trees++;
    }

    ### $toboggan

    $toboggan = ($toboggan + $right_m) % 31;

}

print($trees);