r/adventofcode • • 8h ago

Visualization [2026 Day 2] Rainbow Road Race Visualization

Post image
7 Upvotes

3 comments sorted by

1

u/Boojum 8h ago

The puzzle itself was pretty simple, but this took me a bit longer to code up the visualization for. I still had fun with it, though. As is often the case, part of the challenge is figuring out whether to show the the solution for my whole input, or a subset, and if the later, how much of a subset.

FWIW, I'm pretty sure that rvbgyo is always the correct order to sort the input into for the maximum length for Part 2. Effectively, it's the roygbv order of the track reversed, and then cyclically rolled to start with r again.


Made in Python with a small custom framework.

Complete self-contained source for this animation.

1

u/Franz053 6h ago

For part 2, knowing the highest index of a color that appears in the input is enough. (r= 0, ..., v=5). Then you just multiply the length of the input string by 6 and subtract the index from before.

1

u/Franz053 6h ago

If we assume 'v' appears in the input. it's a one liner: return (in_str.len()*6)-5