fix: reload stats and puzzle
This commit is contained in:
@@ -100,7 +100,7 @@ local function printBanner()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function main()
|
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))
|
local selectedDay = math.max(1, math.min(END_DATE.day, today.day))
|
||||||
if not dates.isInDateRange(START_DATE, today, END_DATE) then
|
if not dates.isInDateRange(START_DATE, today, END_DATE) then
|
||||||
selectedDay = 1
|
selectedDay = 1
|
||||||
@@ -128,7 +128,7 @@ local function main()
|
|||||||
dayStats.puzzle2
|
dayStats.puzzle2
|
||||||
)
|
)
|
||||||
day:show()
|
day:show()
|
||||||
stats = loadStats("aoc/res/stats.json")
|
stats = loadStats("aoc/res/stats.json") or {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -128,7 +128,9 @@ function Day:getInputData()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Day:execPuzzle(puzzleI, data)
|
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 t0 = os.epoch("local")
|
||||||
local result = puzzle.solve(data)
|
local result = puzzle.solve(data)
|
||||||
local t1 = os.epoch("local")
|
local t1 = os.epoch("local")
|
||||||
|
|||||||
@@ -70,4 +70,12 @@ function utils.waitForKey(targetKey)
|
|||||||
end
|
end
|
||||||
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
|
return utils
|
||||||
|
|||||||
Reference in New Issue
Block a user