summaryrefslogtreecommitdiffstats
path: root/2020/day3/toboggan.pl
diff options
context:
space:
mode:
authorYigit Sever2021-12-13 10:38:11 +0300
committerYigit Sever2021-12-13 10:38:11 +0300
commit74b27ccca31bb757c737dd7fdc02f513f57561b2 (patch)
treee27db4cd0873c81a53d32277446d926d176304e0 /2020/day3/toboggan.pl
parent3919f90cfbfbba26c8e39f979280649f5e08aea8 (diff)
parentac8125750abed263619da4cc6d653bb5ab76f007 (diff)
downloadaoc-74b27ccca31bb757c737dd7fdc02f513f57561b2.tar.gz
aoc-74b27ccca31bb757c737dd7fdc02f513f57561b2.tar.bz2
aoc-74b27ccca31bb757c737dd7fdc02f513f57561b2.zip
Merge remote-tracking branch 'origin/main'
Diffstat (limited to '2020/day3/toboggan.pl')
-rw-r--r--2020/day3/toboggan.pl30
1 files changed, 30 insertions, 0 deletions
diff --git a/2020/day3/toboggan.pl b/2020/day3/toboggan.pl
new file mode 100644
index 0000000..d424a83
--- /dev/null
+++ b/2020/day3/toboggan.pl
@@ -0,0 +1,30 @@
1use strict;
2use warnings;
3# use Smart::Comments;
4
5open my $fh, '<', "input" or die "no input present, $!";
6
7my $right_m = 3;
8my $toboggan = 0;
9
10my $trees = 0;
11
12while (my $line = <$fh>) {
13 chomp $line;
14
15 ### $line
16 my $curr = substr($line, $toboggan, 1);
17 ### $curr
18
19 if ($curr eq "#") {
20 $trees++;
21 }
22
23 ### $toboggan
24
25 $toboggan = ($toboggan + $right_m) % 31;
26
27}
28
29print($trees);
30