Day 3 part 1
parent
7a8c02dfab
commit
68ccdaaadd
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
regex="mul\(([0-9]{1,3}),([0-9]{0,3}))"
|
||||
|
||||
acc=0
|
||||
while read line; do
|
||||
if [[ $line =~ $regex ]] then
|
||||
n1=${BASH_REMATCH[1]}
|
||||
n2=${BASH_REMATCH[2]}
|
||||
acc=$(expr $n1 \* $n2 + $acc)
|
||||
fi
|
||||
done <<< $(grep -Eo $regex input.txt)
|
||||
echo $acc
|
Loading…
Reference in New Issue