Day 01 - 03 Dez. 2024

This commit is contained in:
2024-12-03 21:05:54 +01:00
parent 7c310e290e
commit 9c0c7f5df4
10 changed files with 2071 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
# Python Code
# Developer : David Bandeira
import sys,time
import sys,time, re
from helpingFunctions import *
setSampleMode(False)
@@ -16,10 +16,20 @@ filename = getFilename2Data(aocDay)
def taskA (data) -> int:
gameScoreA = 0
for dataRow in data:
for x,y in re.findall(r"mul\((\d+),(\d+)\)",dataRow):
gameScoreA = gameScoreA + (int(x)*int(y))
return gameScoreA
def taskB (data) -> int:
multiplicator = True
gameScoreB = 0
for dataRow in data:
for x,y,do,dont in re.findall("mul\((\d+),(\d+)\)|(do\(\))|(don't\(\))",dataRow):
if do or dont:
multiplicator = bool(do)
else:
gameScoreB = gameScoreB + ((int(x)*int(y))* multiplicator)
return gameScoreB
def task(task: int,data) -> int: