Jeff's Advent of Code 2024 Static Page

Part 1

Details / Spoilers Looks pretty straightforward: use lists, sort them. Tricky part for me is formatting the input data so I can inline it in my code.

Part 2

Details / Spoilers Let's use a map!

Part 1

Using this online tool to pre-process input data to a JSON array

Part 2

Details / Spoilers I found this initially tricky, since it's hard to identify a specific, single invalid item when walking the list and comparing neighbors. I.e. when a problem is found, is it because of the left or right item in the pair? So, instead, I walked the original report line, creating temp reports with each element removed. If any of these temp reports were correct, the original report was also correct.

Part 1

Some interesting parsing...

Details / Spoilers Javascript numeric parsing was trickier than I thought! There are two functions typically used: parseInt() and Number(). parseInt() weirdly ignores *all* non-numeric characters and Number() was allowing through a few weird cases that I didn't bother to get to the bottom of. Finally, I just used Number() along with an extra check using isNaN() to confirm. This seemed to do the trick.

Part 2

A twist, of course! Also, I ran into too many infinite loops :)

Details / Spoilers I had to think a bit how to track the do/don't behavior. In the end, I built a list of index ranges where the operations should be excluded. Then, for every possible operation, I check if its index is within one of the (relatively few) exclusion ranges and exclude it if so.

Part 1

Straightforward, but a bit tedious. Easy to make simple mistakes.

Part 2

Pretty easy once Part 1 was done.

Part 1

Straightforward

Part 2

Had a bug where I was using an array value in place of an index. Oops!

Details / Spoilers To fix the bad updates, my intuition was to swap the values that violated a rule. This made me queasy, since it *seemed* reasonable, but I was nervous because I wasn't convinced of its correctness. I figured I could implement it and see what happens, which worked out in the end (once I fixed my silly mistakes).

Part 1

Straightforward, actually got the correct answer on the first try!

Part 2

Pretty straightforward as well. My simple approach took 1,360 times longer than Part 1 to execute (1.8 sec runtime), which is surprising since it basically repeated Part 1 over 16k times.

Part 1

Let's count in binary and use bitwise operations!

Part 2

TODO: still need to code it...

Part 1

Straightforward, ignoring the usual trivial bugs.

Part 2

Only a minor tweak needed to Part 1.

Part 1

Completed.

Part 2

TODO: need to fix it...

Part 1

Let's search (depth-first, in this case)! Silly bugs for this one: not marking the final spot as visited and initially forgetting to atoi() my input data.

Part 2

A small tweak does the trick!

Part 1

Let's use the modulo operator.

Part 2

TODO: Currently broken :(

Part 1

Let's recursively crawl to identify regions!

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

Pretty simple, though I let the wrapping behavior trip me up initially.

Part 2

Adding a button to step throught...

Steps: 0

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description

Part 1

TODO: description

Part 2

TODO: description