Skip to content

Latest commit

 

History

History
126 lines (73 loc) · 7.06 KB

README.md

File metadata and controls

126 lines (73 loc) · 7.06 KB

Advent of Code 2021

Learning Go by working my way through Advent of Code 2022.

Table of Contents

Daily Impressions

Fairly straight forward problem, but this was my first time writing a Go program so I struggled a ton.

TODO: look at solutions to figure out how to

Good ole rock, nothing beats that

Today was a mess. Had to learn how to write Go code across multiple files.... which is a lot harder than it sounds.

Overall the logic was easy; still struggling with the lnguage

If you work with Go programming, you quickly realize there are no concept sets. However, we can play some tricks with maps and structs to create a set.

Unlike some programming languages, Go does not have any convenience functions to list out the keys or values of a map.

Today was a grind; would've been a few lines if I could do it in Python or TS. I did find golang-set, but wanted to power through using the Go Standard Library which is apparently "batteries included". Not sure what batteries they are talking about; definitely not AA or AAA.

Aside: there is apparently a Go port of lodash.

Another grindy day. Brute forced it instead of checking bounds. I'm mostly fighting my lack of knowledge of Go. Hopefully will have some time in the next few days to read through The Go Programming Language book.

Today was Towers of Hanoi more or less. I gave up on only using the Go Standard Library and installed the fantastic deque library.

Reading input was not a lot of fun, but am learning about a lot of ways to make things easier to process in Go.

First time I didn't fight Golang to get the solution done. But it was a very easy problem which used all of the knowledge I accquired from previous puzzles.

Also it was very easy to modify part 1 to solve part 2.

I used ChatGPT to help me parse the input into a tree and to create a print function that takes my tree and prints it out nicely. Learned more feature of Go this way than by actually reading a book (which has been hard to do on vacation). The GPT generated code wasn't perfect, but it helped me get started.

Finally starting to feel comfortable in Go. Not struggling as much as I was for the first few days. I'm still not 100% sure on pointers and the & vs * operators, but I think that will come in through time.

I brute forced today's challenge using a mapping. Could probably clean it up with 2D arrays and direction vectors to reduce the code, but it's probably not worth it.

Definitely need to look at other people's Go solutions to ensure I'm doing things in "The Go Way."

I finally broke down and started writing methods for my struts. This was another method which required (x, y) coordinates so I created a utility module for Point operations.

Some day I need to understand how imaginary numbers make this a lot easier to handle.

Today's question was hard to parse, but the actual solution fairly straight forward. First day I felt like my solution is not that bad for Go -- a language I started learning at the end of November.

Reading this in with Go was painful. I should have looked at the input because I went down the path of installing maja42/goval to handle the operation. The new = old * old totally threw me for a loop.

Part 2 took forever. I tried out big.Int, but it wasn't the right solution. Found a hint on Slack / Reddit that helped me get the answer. I always get caught by LCM-type questions.

Aside: this solution has a really clean way of parsing input

This was a "shortest path" problem that took me a bit longer than normal to code up. I was just treating it as a find a path to X vs find the shortest path to X. My idea in part 1 was to work backwards, but I didn't code it that way until part 2 which required it.

Day 13

Stashing -- will come back to

Today was a fairly straight forward puzzle. After struggling with Day 13; I decided to skip it and come back to it later when I could read it with a fresh set of eyes.

It was nice to have a easy puzzle today which could be simulated very quickly in Go. Not sure if this puzzle required a trick or not.

Fun puzzle! For part 1, I tired to count the instances where y=limit. Solution ran pretty fast. Brute forcing part 1 for part 2 did not seem like it would work today. I was stuck for a few hours until I saw a Reddit animation with a diamond-shaped bounding box.

That gave me an idea for an algorithm. Find all the boundary points for each of the signals + manhattan distance to closest beacon + 1. Then filter out the points that don't work. This gave me the correct result in ~30-35 seconds (on average). Not perfect, but it does the job.

TODO -- look up other people's solutions for this one

Day 16

Go has python style capture groups which is pretty awesome!

Spent a lot of time on this one but still can't get the example to work for more than 1 agent. Will come back to it with Python when I have some time.