diff --git a/1/day1-1.awk b/1/day1-1.awk new file mode 100755 index 0000000..7c763d4 --- /dev/null +++ b/1/day1-1.awk @@ -0,0 +1 @@ +BEGIN{sum=0; max_sum=0} {if (NF != 0) {sum+=$1} else {if (sum > max_sum) {max_sum=sum}; sum=0}} END{print max_sum} diff --git a/1/day1-2.sh b/1/day1-2.sh new file mode 100755 index 0000000..6ccd659 --- /dev/null +++ b/1/day1-2.sh @@ -0,0 +1,2 @@ +#!/bin/bash +awk 'BEGIN{sum=0} {if (NF != 0) {sum+=$1} else {print sum; sum=0}}' input.txt | sort -n | tail -n 3 | awk 'BEGIN{sum=0} {sum+=$1} END{print sum}'