notes by alifeee profile picture rss

return to notes / blog / website / weeknotes / linktree

here I may post some short, text-only notes, mostly about programming. source code.

tags: all (19), scripting (5), bash (4), linux (3), html (2), markdown (2), obsidian (2), shortcuts (2), ActivityPub (1), advent-of-code (1) ............ see all (+15)

viewing a single note

you should do Advent of Code using bash # source

tags: advent-of-code, bash • 319 'words', 96 secs @ 200wpm

last year I did Advent of Code in bash.

you should do it too.

people often attempt it in a programming language which is new to them, so they can have a nice time learning how to use it. I think this language should be "the terminal".

I learnt a lot about sed and awk, and more general things about bash like pipes, redirection, stdout and stderr, and reading from and editing files.

Ever since, I've learnt more and more about the terminal and become more comfortable there, and now I feel comfortable doing some nice loops and commands, such that I process a lot of data purely on the terminal, like some of the maps I've been making recently.

My Advent of Code 2023 solutions are in this GitHub repository: https://github.com/alifeee/advent-of-code-2023

They're mostly in bash, and they mostly solve quite quickly. I stopped after day 12 because things got too confusing and "dynamic programming", and my method of programming ("not having done a computer science degree") doesn't do well with recursion and complicated stuff.

I used a lot of awk, which I found very fun, and now I probably use awk almost every day.

For fun, here are how many times each of awk's string functions appear in my solutions

$ while read cmd; do printf "${cmd}: "; egrep --exclude=awkstrings.md -r "${cmd}" | wc -l; done <<< $(cat awkstrings.md | pcregrep -o1 '^- `([^\(`]*)')
asort: 0
gensub: 7
gsub: 10
index: 49
length: 54
match: 21
patsplit: 4
split: 24
sprintf: 1
strtonum: 0
sub: 47
substr: 20
tolower: 0
toupper: 0

awk and bash were probably terrible ways to solve complex problems, but they were certainly fun in the early days of it.

you should give it a go.

back to top back to main page