added task 2

This commit is contained in:
matthias@arch 2022-12-03 01:33:53 +01:00
parent 17599f4fe7
commit 032f129cb2
2 changed files with 3 additions and 0 deletions

1
1/day1-1.awk Executable file
View File

@ -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}

2
1/day1-2.sh Executable file
View File

@ -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}'