thomas_2023/day_1/part1.fish

14 lines
237 B
Fish
Raw Normal View History

set sum 0
for line in $(cat input.txt)
set first $(string match -gr "(\d)" $line)
set last $(string match -gr "(\d)(?!.*\d)" $line)
echo $line
set n $first$last
set sum $(math $sum + $n)
echo "-"
end
echo $sum