aboutsummaryrefslogtreecommitdiffstats
path: root/day1/solution.sh
blob: 94c763ba53a7c3a9238680d1fefc808ceb449918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env bash

table=$(cat input.txt | sort | uniq -c | sort)

most=$(tail -n3 <<< "$table")
least=$(head -n3 <<< "$table")

calc(){
    awk 'BEGIN { p = 1 } { p *= $2 } END { print p }'
}

calc <<< "$most"
calc <<< "$least"