Will Thomas' blog

AoC 2025 Day 3

2025-12-20, Saturday


Just finished part 2 of this, a couple of days removed from part 1. Phew!

I had written my part 1 code in a very straightforward manner, a blunt, brute-force solution. Part 2 required much the same solution, but more generalised. "Fair enough", thought I; "how hard could that be?"

In translating to a more general solution, I found difficulties getting my head around correctly indexing. I had to use the example on the AoC page to help diagnose where it was going wrong, as those are shorter than the input.

I'm sure there are far simpler methods some people came up with, perhaps some regex or similar. This was the kind of puzzle also that felt as though there's probably some built-in operator in Python for this exact situation.

But I was quite happy once I'd eventually gotten it sorted. Even if it is a tad messy!