Satrtscript and helper functions

This commit is contained in:
2024-11-09 13:16:28 +01:00
parent 9d50ead5a0
commit 290d33cf12
56 changed files with 92 additions and 0 deletions

Binary file not shown.

43
2024/day00.py Normal file
View File

@@ -0,0 +1,43 @@
# AOC Day Script Day XX
# Date : 20XX.12.XX
# Python Code
# Developer : David Bandeira
import sys,time
from helpingFunctions import *
setSampleMode(False)
gameScoreA=0
gameScoreB=0
aocDay = identifyDay(sys.argv[0])
path = getPath2Data(aocDay)
filename = getFilename2Data(aocDay)
def task(task: int,data) -> int:
score=0
if task == 1:
global gameScoreA
score = gameScoreA
elif task == 2:
global gameScoreB
score = gameScoreB
return score
def main():
showSampleMode()
try:
data = open(path+'/'+filename).read().strip().split('\n')
except:
print ('no inputfile found')
print ('please check file %s on path %s' % (filename, path))
quit()
st=time.time()
print ('Day '+aocDay+': Tasks 1: '+ str(task(1,data))+ ' executation time: ' + str(int((time.time()-st)*1000)) + 'ms')
st=time.time()
print ('Day '+aocDay+': Tasks 2: '+ str(task(2,data))+ ' executation time: ' + str(int((time.time()-st)*1000)) + 'ms')
if __name__ == "__main__":
main()

0
2024/day00/input.day00 Normal file
View File

0
2024/day00/sample.day00 Normal file
View File

0
2024/day01/input.day01 Normal file
View File

0
2024/day01/sample.day01 Normal file
View File

0
2024/day02/input.day02 Normal file
View File

0
2024/day02/sample.day02 Normal file
View File

0
2024/day03/input.day03 Normal file
View File

0
2024/day03/sample.day03 Normal file
View File

0
2024/day04/input.day04 Normal file
View File

0
2024/day04/sample.day04 Normal file
View File

0
2024/day05/input.day05 Normal file
View File

0
2024/day05/sample.day05 Normal file
View File

0
2024/day06/input.day06 Normal file
View File

0
2024/day06/sample.day06 Normal file
View File

0
2024/day07/input.day07 Normal file
View File

0
2024/day07/sample.day07 Normal file
View File

0
2024/day08/input.day08 Normal file
View File

0
2024/day08/sample.day08 Normal file
View File

0
2024/day09/input.day09 Normal file
View File

0
2024/day09/sample.day09 Normal file
View File

0
2024/day10/input.day10 Normal file
View File

0
2024/day10/sample.day10 Normal file
View File

0
2024/day11/input.day11 Normal file
View File

0
2024/day11/sample.day11 Normal file
View File

0
2024/day12/input.day12 Normal file
View File

0
2024/day12/sample.day12 Normal file
View File

0
2024/day13/input.day13 Normal file
View File

0
2024/day13/sample.day13 Normal file
View File

0
2024/day14/input.day14 Normal file
View File

0
2024/day14/sample.day14 Normal file
View File

0
2024/day15/input.day15 Normal file
View File

0
2024/day15/sample.day15 Normal file
View File

0
2024/day16/input.day16 Normal file
View File

0
2024/day16/sample.day16 Normal file
View File

0
2024/day17/input.day17 Normal file
View File

0
2024/day17/sample.day17 Normal file
View File

0
2024/day18/input.day18 Normal file
View File

0
2024/day18/sample.day18 Normal file
View File

0
2024/day19/input.day19 Normal file
View File

0
2024/day19/sample.day19 Normal file
View File

0
2024/day20/input.day20 Normal file
View File

0
2024/day20/sample.day20 Normal file
View File

0
2024/day21/input.day21 Normal file
View File

0
2024/day21/sample.day21 Normal file
View File

0
2024/day22/input.day22 Normal file
View File

0
2024/day22/sample.day22 Normal file
View File

0
2024/day23/input.day23 Normal file
View File

0
2024/day23/sample.day23 Normal file
View File

0
2024/day24/input.day24 Normal file
View File

0
2024/day24/sample.day24 Normal file
View File

0
2024/day25/input.day25 Normal file
View File

0
2024/day25/sample.day25 Normal file
View File

35
2024/helpingFunctions.py Normal file
View File

@@ -0,0 +1,35 @@
import sys, os
sampleMode = False
def identifyDay(inputArgument):
twoDigitsDay = '00'
day = 0 if (inputArgument[inputArgument.rfind('/')+4:inputArgument.rfind('.')] == 'X') else inputArgument[inputArgument.rfind('/')+4:inputArgument.rfind('.')]
twoDigitsDay = str(day).zfill(2)
return twoDigitsDay
def setSampleMode(mode:bool):
global sampleMode
if (mode) : sampleMode = True
return
def getSampleMode():
return sampleMode
def showSampleMode():
if ( getSampleMode() ):
print ("----------------------")
print ("Running im Sample Mode")
print ("----------------------")
return
def getPath2Data(aocDay):
return './day'+str(aocDay)+'/'
def getFilename2Data(aocDay):
dataFilename = 'sample.day'+str(aocDay) if ( sampleMode ) else 'data.day'+str(aocDay)
return dataFilename
def readDataFile (path, filename):
data = ''
return data