#!/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"