Added solutions
This commit is contained in:
1000
2024/day-1/input.txt
Normal file
1000
2024/day-1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
10
2024/day-1/solution-1.sh
Normal file
10
2024/day-1/solution-1.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
INPUT_FILE=input.txt
|
||||
|
||||
paste \
|
||||
<(awk '{print $1}' $INPUT_FILE | sort -n ) \
|
||||
<(awk '{print $2}' $INPUT_FILE | sort -n ) |
|
||||
awk '{ $1 > $2 ? diff = ($1 - $2) : diff = ($2 - $1) ; print diff}' |
|
||||
paste -s -d "+" |
|
||||
bc
|
8
2024/day-1/solution-2.sh
Normal file
8
2024/day-1/solution-2.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
join -1 2 -2 2 \
|
||||
<( awk '{print $2}' input.txt | sort -n | uniq -c ) \
|
||||
<( awk '{print $1}' input.txt | sort -n | uniq -c ) |
|
||||
awk '{print $1 * $2 * $3 }' |
|
||||
paste -s -d "+" |
|
||||
bc
|
Reference in New Issue
Block a user