+ day 1, part 2

meow
Dominique Liberda 2022-12-01 03:20:28 -05:00
parent 599a7e7595
commit 19c4e6238b
3 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,5 @@
# Day 1
`cat data | ./meow.sh`
`cat data | ./nyaa.sh`

View File

@ -1,4 +1,7 @@
#!/bin/bash
n=1
[[ "$1" != '' ]] && n=$1
meow=()
sum=0
@ -11,4 +14,4 @@ while read line; do
fi
done
echo ${meow[@]} | tr ' ' '\n' | sort -n | tail -n1
echo ${meow[@]} | tr ' ' '\n' | sort -n | tail -n$n

4
01/nyaa.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
in=$(./meow.sh 3 | tr '\n' '+' | sed -E 's/\+$//')
echo $((in))