Day 01 - 03 Dez. 2024
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user