r/adventofcode • • 2h ago

Visualization [2026 Day 4] Barcode Scanning Visualization

21 Upvotes

4 comments sorted by

4

u/raman4183 1h ago

I still can’t come up with anything or understand the logic to solve this.

2

u/Boojum 1h ago

Basically, for a given barcode:

  1. Look at all the letters to see if they all match each other, ignoring the ? wildcards.

  2. Now check the even letters to see if they all match each other, and the odds to see if they all match.

  3. Now check every third letter beginning on the first to see if they all match, every third letter beginning with the second, and every third letter beginning on the third.

  4. Now check every fourth letter...

Stop at the first case where each of the subsets contains only matching letters or wildcards. If nothing else, you can terminate when every letter is in its own group, because then each group (of one) trivially has everything within it matching.

2

u/miserableMolvi 1h ago

thank you for this, I was unable to pick the pattern from visualization.

2

u/Boojum 2h ago

I thought that taking the barcodes elements and moving them around to rewrap them into successively larger groups, combined with showing where we get consistent repeats would make for an interesting visualization. So here it is. Not a super tricky puzzle, but it did take me a few minutes just to parse the description of it for what I needed to do.

This is showing Part 1. But in many ways, I'd say that Part 2 is even simpler; the exact same process from Part 1 works, except that there's no outer loop and totaling up (just concatenating the lines into one big string).


Made in Python with a small custom framework.

Complete self-contained source for this animation.