From 4bb6f8d06c0e384f3394012b1d48da58ed28cc5e Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 12 Dec 2021 01:24:32 +0300 Subject: 2020, tracking --- 2020/day3/toboggan.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 2020/day3/toboggan.pl (limited to '2020/day3/toboggan.pl') 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 @@ +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); + -- cgit v1.2.3-70-g09d2