Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Last active December 5, 2022 01:56
Show Gist options
  • Save rwcitek/aaa1720f1cd4ea7c8d50182b769e7b36 to your computer and use it in GitHub Desktop.
Save rwcitek/aaa1720f1cd4ea7c8d50182b769e7b36 to your computer and use it in GitHub Desktop.
Advent of Code 2022 - day 01
# Using a shell pipeline of awk, bc, sort, head in Docker with the Alpine image
<<'eof' docker container run --rm -i alpine
{ cat <<'eof2'
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
eof2
} |
awk -v RS='\n\n' '{ gsub("\n","+") } ; { print }' |
bc |
cat -n |
sort -k2,2nr |
head -1
eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment