Comment on
We give it all (and more) away to the worst of us. There often is nothing left for ourselves at the end of the day.
I'm in this picture and I don't like it.
Comment on
We give it all (and more) away to the worst of us. There often is nothing left for ourselves at the end of the day.
I'm in this picture and I don't like it.
Comment on
🍷 - 2024 DAY 3 SOLUTIONS -🍷
Python
def process(input, part2=False):
if part2:
input = re.sub(r'don\'t\(\).+?do\(\)', '', input) # remove everything between don't() and do()
total = [ int(i[0]) * int(i[1]) for i in re.findall(r'mul\((\d+),(\d+)\)', input) ]
return sum(total)
Given the structure of the input file, we just have to ignore everything between don't() and do(), so remove those from the instructions before processing.
Comment on
🍷 - 2024 DAY 3 SOLUTIONS -🍷
Reply in thread
I did wonder if that might be the case, I must have been lucky with my input.