Visualizing Advent of Code Problems


I see cool data and algorithm visualizations all the time,1 but I’ve never really tried making any of my own. Today’s Advent of Code problem seemed to lend itself to visualization fairly well, so I decided to give it a shot!

Harder than I thought

Day 4 was a straight forward solve, so porting my zig solution to gdscript was quick. Wiring it up to a solve button and some simple drawings was also not too bad, but I knowingly cut a lot of corners.

Timing and controlling execution of the subject code is a key part of good visualizations that I just hacked through by inserting oneshot timers in my main loop. This works fine…ish on a problem like this, where the visual only needs to be updated once per iteration of the algorithm, but more complex problems would want a more granular way of updating the visuals. Something to think about for next time.

I didn’t want to spend hours on this so the visual itself is super rushed: an off-center grid of colored boxes that look bad because they’re 16:9 not 1:1. There’s no animation either; updates are immediate.

Oh well, motivation to learn more Godot and graphics programming I guess.

Maybe I’ll try again if another aoc problem seems like an easy target.

Result

It looks pretty rough, but now I think I know what I need to work on for next time.

Source code for the visuals.

Thanks for reading!


  1. A few people who create great visualizations / animations: Sebastian Lauge, Logan Smith, Freya Holmér, 3Blue1Brown, Acerola. check them out!↩︎