From 62603926dc419c18b6cc0018873a918a3ec0af76 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Tue, 3 Dec 2024 14:16:48 +0100 Subject: [PATCH] docs: Add Part Two problem description to Day 3 README --- lib/advent_code2024/solutions/day03/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/advent_code2024/solutions/day03/README.md b/lib/advent_code2024/solutions/day03/README.md index a23e77a..72f6dfa 100644 --- a/lib/advent_code2024/solutions/day03/README.md +++ b/lib/advent_code2024/solutions/day03/README.md @@ -38,3 +38,21 @@ Total = (2*4) + (5*5) + (11*8) + (8*5) = 161 ## Task Scan the corrupted memory for valid mul instructions and sum their results. + +--- Part Two --- +As you scan through the corrupted memory, you notice that some of the conditional statements are also still intact. If you handle some of the uncorrupted conditional statements in the program, you might be able to get an even more accurate result. + +There are two new instructions you'll need to handle: + +The do() instruction enables future mul instructions. +The don't() instruction disables future mul instructions. +Only the most recent do() or don't() instruction applies. At the beginning of the program, mul instructions are enabled. + +For example: + +xmul(2,4)&mul[3,7]!^don't()\_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5)) +This corrupted memory is similar to the example from before, but this time the mul(5,5) and mul(11,8) instructions are disabled because there is a don't() instruction before them. The other mul instructions function normally, including the one at the end that gets re-enabled by a do() instruction. + +This time, the sum of the results is 48 (2*4 + 8*5). + +Handle the new instructions; what do you get if you add up all of the results of just the enabled multiplications?