fix: reload stats and puzzle
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user