Vigyata.AI
Is this your channel?

ADVENT OF CODE 2024 | DAY 3 Jackie's Python Solution

5.3K views· 222 likes· 5:27· Dec 5, 2024

Subscribe for more content like this :) 0:00 coding challenge 1:18 PART 1 solution 3:00 PART 2 solution #adventofcode #vlogmas #programming

About This Video

In this Advent of Code 2024 Day 3 video (“Mull It Over”), I’m tackling a messy memory dump from a North Pole shop computer where the only thing we can trust is the occasional valid multiplication instruction. The catch is that the input is full of junk characters, so the job is basically: find every real-looking mul(x,y), multiply the two numbers, and add everything up. I solved Part 1 in Python using regex (yes… regex… my personal villain), and I show how I build a pattern that not only matches mul( , ) but also extracts the digits directly so I can loop through the (x, y) pairs and sum the products. Then Part 2 arrives and I start crying a little, because now the memory includes do and don’t instructions that enable/disable whether future multiplications should count. By default everything starts enabled, do turns counting on, and don’t turns it off. My approach was to filter the memory first: split on do, then split each segment on don’t and only keep the part before don’t. In theory that should leave only the “active” regions for multiplication, but I didn’t get the right answer and I couldn’t figure out why—so if you have a clean solution for Part 2, I genuinely want it so I can get my star.

Frequently Asked Questions

🎬 More from CS Jackie