13 lines
237 B
Fish
Executable file
13 lines
237 B
Fish
Executable file
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
|