adventofcode/2020/3/trajectory.fish
2022-12-01 21:02:00 +01:00

17 lines
300 B
Fish
Executable File

#!/usr/bin/fish
set lines (cat input)
set pos 0
set trees 0
for val in $lines
set width (string length $val)
set char (string sub -s (math $pos + 1) -l 1 $val)
set pos (math "($pos + 3) % $width")
if test "$char" = "#"
set trees (math $trees + 1)
end
end
echo "total nr of trees is $trees"