Nim
Almost caught up. Not much to say about this one. Part 1 was a freebie. Part 2 had a convoluted description, but was still pretty easy.
Almost caught up. Not much to say about this one. Part 1 was a freebie. Part 2 had a convoluted description, but was still pretty easy.
Getting caught up slowly after spending way too long on day 12. I'll be busy this weekend though, so I'll probably fall further behind.
Part 2 looked daunting at first, as I knew brute-forcing 1 billion iterations wouldn't be practical. I did some premature optimization anyway, pre-calculating north/south and east/west runs in which the round rocks would be able to travel.
At first I figured maybe the rocks would eventually reach a stable configuration, so I added a check to detect if the current iteration matches the previous one. It never triggered, so I dumped some of the grid states and it became obvious that there was a cycle occurring. I probably should have guessed this in advance. The spin cycle is effectively a pseudorandom number generator, and all PRNGs eventually cycle. Good PRNGs have a very long cycle length, but this one isn't very good.
I added a hash table, mapping the state of each iteration to the next one. Once a value is added that already exists in the table as a key, there's a complete cycle. At that point it's just a matter of walking the cycle to determine it's length, and calculating from there.
This one was a nice change of pace after the disaster of day 12. For part 1 I kept a list of valid column indexes, and checked those columns in each row for reflections, eliminating columns from the list as I went. To find vertical reflections, I just transposed the grid first.
Part 2 looked daunting at first, but I just needed to add a smudges
counter to each column candidate, eliminating them when their counter reaches 2. For scoring, just count the 1-smudge columns.
Huh, I wasn't expecting more Gundam Seed after almost 20 years. MyAnimeList link for English speakers.
Approached part 1 in the expected way, by expanding the grid. For part 2, I left the grid alone and just adjusted the galaxy location vectors based on how many empty rows and columns there were above and to the left of them. I divided my final totals by 2 instead of bothering with any fancy combinatoric iterators.
Unfortunately then it'll be broken for kbin users. I can do it anyway though if the bot is too annoying, just lmk.
I got a late start on part 1, and then had to sleep on part 2. Just finished everything up with a little time to spare before day 11.
Part 2 probably would have been easier if I knew more about image processing, but I managed:
.
tiles.
tiles that are connected to the outside edges of the grid with O
tilesO
tile at each step. Stopped when one was found, and recorded whether it was to the left or right of the path..
tiles with I
, and counted themCode:
Though also if you plan to appendix carry, it would be good to look into how safe the 1911 is for that. Since it's an older design, there may be additional concerns about having it pointed at your femoral artery.
I love these memes that turn into threads full of vim tips. You really can do anything within vim. You can even exit vim!: !killall vim
Nim
I'm caught up!
This one was pretty straighforward. Iterate through the beam path, recursively creating new beams when you hit splitters. The only gotcha is that you need a way to detect infinite loops that can be created by splitters. I opted to record energized non-special tiles as
-
or|
, depending on which way the beam was traveling, and then abort any path that retreads those tiles in the same way. I meant to also use+
for where the beams cross, but I forgot and it turned out not to be necessary.Part 2 was pretty trivial once the code for part 1 was written.