#Advent of Code
My advent of code solutions.
Currently, I only have 2020-2021, written in Go (I'm kinda learning the
language).
These are only part 2 solutions, although many of them have commented-out part 1
solutions visible as well.
Each directory is a day; in it, there is one Go file containing the part 2 (and
commented part 1?) solution. My problem input is "input"; the example input will
be "input2" and so on.
#Why is my code so verbose
People keep asking me this. There are a couple of reasons.
- I don't care.
- I hate all the clever tricks that people use to write super concise code, in
any language.
- I don't like writing utility functions.
- Go does not have an expansive standard library. There are limited functional
programming constructs (map, filter, etc.). There are few data structures (no
stacks or queues or sets), so I have to write more code handling these things
by hand. There's no "element in map" function. There's a whole bunch of stuff
like this. Most of this is probably not a problem if you use Go in its
intended use case (network programming/web backend/whatever you want to call
it) but it makes AoC weird.
- I'm absolutely not into including libraries from the Internet to address this.
- Go types and errors are funny (e.g. int and int64 are absolutely not
compatible; I know this is not unique to Golang but my day job is C++ so it's
weird to me) and they mean I need extra typecasts and error discarding all
over the place. Runes vs bytes vs single-character strings is kinda hard to
deal with if you have the kind of string parsing that some AoC puzzles
require.
- I don't know the language all that well so I sometimes make poor programming
choices.
- I hate looking up functions when I could just code by hand.
- I tend to copy/paste for input parsing and case handling, so there's a bunch
of weird duplicate code that wouldn't have to exist if I was coding "right" or
"slower".
- I hate string formatting so I write lots of code for that.