Browse Source

Use $1 as puzzle input

master
mid-kid 12 months ago
parent
commit
06e977510c
  1. 4
      d01.sh

4
d01.sh

@ -5,7 +5,7 @@ while read line; do
num1="$(echo "$line" | sed -n 's/^[^0-9]*\([0-9]\).*/\1/p')" num1="$(echo "$line" | sed -n 's/^[^0-9]*\([0-9]\).*/\1/p')"
num2="$(echo "$line" | sed -n 's/.*\([0-9]\)[^0-9]*$/\1/p')" num2="$(echo "$line" | sed -n 's/.*\([0-9]\)[^0-9]*$/\1/p')"
sum=$(( $sum + $num1$num2 )) sum=$(( $sum + $num1$num2 ))
done < d01_input.txt done < "$1"
echo "$sum" echo "$sum"
sum=0 sum=0
@ -35,5 +35,5 @@ while read line; do
num1="$(echo "$line1" | sed -n 's/^[^0-9]*\([0-9]\).*/\1/p')" num1="$(echo "$line1" | sed -n 's/^[^0-9]*\([0-9]\).*/\1/p')"
num2="$(echo "$line2" | sed -n 's/.*\([0-9]\)[^0-9]*$/\1/p')" num2="$(echo "$line2" | sed -n 's/.*\([0-9]\)[^0-9]*$/\1/p')"
sum=$(( $sum + $num1$num2 )) sum=$(( $sum + $num1$num2 ))
done < d01_input.txt done < "$1"
echo "$sum" echo "$sum"

Loading…
Cancel
Save