update 24.12.04
This commit is contained in:
@@ -3,23 +3,65 @@
|
||||
# Python Code
|
||||
# Developer : David Bandeira
|
||||
|
||||
import sys,time
|
||||
import sys,time #,re2
|
||||
from helpingFunctions import *
|
||||
|
||||
setSampleMode(False)
|
||||
setSampleMode(True)
|
||||
|
||||
aocDay = identifyDay(sys.argv[0])
|
||||
aocYear = identifyYear(sys.argv[0])
|
||||
|
||||
path = getPath2Data(aocDay,aocYear)
|
||||
filename = getFilename2Data(aocDay)
|
||||
|
||||
def checkNextChar(inputChar):
|
||||
return 0
|
||||
|
||||
def countXMAS2(data):
|
||||
#ret = re2.findall("M.M\n.A.\nS.S", data, rotate=True)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
def countXMAS(dataMatrix,searchWord):
|
||||
moves = [-1,0,1]
|
||||
findings = {}
|
||||
for x in range(len(dataMatrix)):
|
||||
for y in range(len(dataMatrix[x])):
|
||||
if dataMatrix[x][y] == searchWord[:1]:
|
||||
for moveLength in range(1,len(searchWord)):
|
||||
for moveX in moves:
|
||||
for moveY in moves:
|
||||
findingKey=(x,y,moveX,moveY)
|
||||
try:
|
||||
findings[findingKey] = findings[findingKey]
|
||||
except:
|
||||
findings[findingKey] = dataMatrix[x][y]
|
||||
|
||||
indexX = x+moveLength*moveX
|
||||
indexY = y+moveLength*moveY
|
||||
if (indexX < 0 or indexY < 0):
|
||||
findings[findingKey] = findings[findingKey] + " "
|
||||
else:
|
||||
try:
|
||||
findings[findingKey] = findings[findingKey] + dataMatrix[indexX][indexY]
|
||||
except:
|
||||
findings[findingKey] = findings[findingKey] + " "
|
||||
return list(findings.values())
|
||||
|
||||
def taskA (data) -> int:
|
||||
gameScoreA = 0
|
||||
dataMatrix=[]
|
||||
searchWord = 'XMAS'
|
||||
for line in data:
|
||||
dataMatrix.append(list(line))
|
||||
findings = countXMAS(dataMatrix,searchWord)
|
||||
gameScoreA = findings.count(searchWord)
|
||||
return gameScoreA
|
||||
|
||||
def taskB (data) -> int:
|
||||
gameScoreB = 0
|
||||
gameScoreB = countXMAS2(data)
|
||||
return gameScoreB
|
||||
|
||||
def task(task: int,data) -> int:
|
||||
|
||||
Reference in New Issue
Block a user