Last active
December 20, 2024 01:25
-
-
Save aramperes/4b52147128e36beef109a65e5d825da9 to your computer and use it in GitHub Desktop.
Advent of Code 2024 Day 1 - Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dbg="+x" | |
set "$dbg" | |
in="$1" | |
awk '{print $1}' "$in" |\ | |
sort |\ | |
nl -bt -nln |\ | |
xargs -I '{}' bash $dbg -c "\\ | |
awk '{print \$2}' \"$in\" |\\ | |
sort |\\ | |
tail -n+\$(\\ | |
echo -n '{}' | awk '{printf \$1}'\\ | |
) |\\ | |
head -1 |\\ | |
awk \"{printf \\\"\\ | |
(\$(echo -n {} | cut -d' ' -f2)-%s)\\\", \\\$1\\ | |
}\" |\\ | |
xargs -I '@@' bash $dbg -c '\\ | |
echo \$(@@) |\\ | |
tr -d - | |
' | |
" |\ | |
xargs |\ | |
sed -e 's/\ /+/g' |\ | |
xargs -I '{}' bash $dbg -c 'echo $(({}))' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dbg="+x" | |
set "$dbg" | |
in="$1" | |
awk '{print $1}' "$1" |\ | |
xargs -I '{}' bash $dbg -c "\\ | |
awk '\$2 == \"{}\"' \"$in\" |\\ | |
wc -l |\\ | |
xargs -0 printf \"{}*%s\" | |
" |\ | |
xargs |\ | |
sed -e 's/\ /+/g' |\ | |
xargs -I '{}' bash $dbg -c 'echo $(({}))' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 4 | |
4 3 | |
2 5 | |
1 3 | |
3 9 | |
3 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment