Day 01 - 03 Dez. 2024
This commit is contained in:
@@ -13,13 +13,25 @@ aocYear = identifyYear(sys.argv[0])
|
||||
|
||||
path = getPath2Data(aocDay,aocYear)
|
||||
filename = getFilename2Data(aocDay)
|
||||
|
||||
|
||||
def isCorrect(row):
|
||||
inc = [row[i + 1] - row[i] for i in range(len(row) - 1)]
|
||||
if set(inc) <= {1, 2, 3} or set(inc) <= {-1, -2, -3}:
|
||||
return True
|
||||
return False
|
||||
|
||||
def taskA (data) -> int:
|
||||
gameScoreA = 0
|
||||
for report in data:
|
||||
reportData = [int(data) for data in report.split(' ')]
|
||||
gameScoreA = gameScoreA + isCorrect(reportData)
|
||||
return gameScoreA
|
||||
|
||||
def taskB (data) -> int:
|
||||
gameScoreB = 0
|
||||
for report in data:
|
||||
reportData = [int(data) for data in report.split(' ')]
|
||||
gameScoreB = gameScoreB +any([isCorrect(reportData[:i] + reportData[i + 1:]) for i in range(len(reportData))])
|
||||
return gameScoreB
|
||||
|
||||
def task(task: int,data) -> int:
|
||||
|
||||
Reference in New Issue
Block a user