4
votes
Day 4: Perilous Pier
Today's problem description: https://adventofcode.com/2026/day/4
Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):
<details>
<summary>Part 1</summary>
```python
Your code here.
```
</details>
This was a fun one (albeit easier than yesterday's, I think)! Part 2, though, confused me a little bit... AoC has done these kinds of puzzles a bunch in the past, where Part 2 does nothing but increase the input size to prevent brute forcing, but my solution for Part 1 already didn't brute force, and was able to solve Part 2 instantly. So I'm assuming there's a naive solution I lucked into not finding, maybe? I also found it strange that the puzzle description made a point of describing how instructions could be one of six colors, since my solution doesn't care about that at all.
Solution (Lily)
just a classic AoC red herring. it wasn't relevant to my solution either.
I liked this one; a fun problem statement to untangle.
Solution (C#)
I realized that you can pad any input with an arbitrary number of
?s without changing the answer, so for each line I shoved a bunch on the end so I wouldn't have to worry about overshooting the string length. Then, for each substring length, just ensure each character at that position is?or uniquely one other character. Pretty much the same thing everyone else did, it seems.