fix: reload stats and puzzle

This commit is contained in:
2025-11-28 21:15:33 +01:00
parent 080f2b51c7
commit d2752a04b6
3 changed files with 13 additions and 3 deletions

View File

@@ -100,7 +100,7 @@ local function printBanner()
end
local function main()
local stats = loadStats("aoc/res/stats.json")
local stats = loadStats("aoc/res/stats.json") or {}
local selectedDay = math.max(1, math.min(END_DATE.day, today.day))
if not dates.isInDateRange(START_DATE, today, END_DATE) then
selectedDay = 1
@@ -128,7 +128,7 @@ local function main()
dayStats.puzzle2
)
day:show()
stats = loadStats("aoc/res/stats.json")
stats = loadStats("aoc/res/stats.json") or {}
end
end
end

View File

@@ -128,7 +128,9 @@ function Day:getInputData()
end
function Day:execPuzzle(puzzleI, data)
local puzzle = require(self:srcDir() .. "/puzzle" .. puzzleI)
local path = self:srcDir() .. "/puzzle" .. puzzleI
package.loaded[path] = nil
local puzzle = require(path)
local t0 = os.epoch("local")
local result = puzzle.solve(data)
local t1 = os.epoch("local")

View File

@@ -70,4 +70,12 @@ function utils.waitForKey(targetKey)
end
end
function utils.splitLines(data)
local t = {}
for str in string.gmatch(data, "([^\n]+)") do
table.insert(t, str)
end
return t
end
return utils