| 1 | ||
| 1 | ||
| 1 | ||
| 1 | ||
| 1 |
We did this last year. But this year I guess we are already behind. If you don't know what Advent of Code is, it is a series of coding challenges with a new one every day. It would typically run starting on the first until the 25th. But this year they are only going to the twelth.
I'm not always sure how to format these. I may just wing it. Folks can share their solutions in code blocks here or give a link to a repo if they would like. Advent of code starts off pretty easy and then ramps up to some genuinely hard problems. So I would encourage people to try the first few even if you are a beginner. You can even pipe it into AI if that is your current level.
Also each day comes in two parts. The second part is usually harder than the first. Because I am starting behind anyone is welcome to start a thread if you are ahead of me.
Here is my solution to part one:
I've yet to figure it out but for some reason applying circleMod to the input in addition to pointer changed the output. In theory if the circleMod is working correctly it shouldn't make a difference. But this is the nature of advent of code. Get the solution and move on. I'm working on part 2 now.
Here is my code for part two. The big change was counting every time the dial crosses zero. I like doing things in functional ways even if I'm in a procedural language. This is why I did an extra step of input reduction at the start. Progressive mapping to equivalent more simple states is the heart of how to solve things with functional esoterics. I did fail at my first attempt at part two. The key thing was making a move function that allows isolating code that needs to consider edge cases away from a for loop. Loops should be tight with minimal logic in them. This function also manages a state update to the pointer. It has a dial position as an argument and also treats it as part of a multi-part return value. This is also a classically functional way to do things. It's also close to how it would be done in Elixir in case I feel like translating it.