diff --git a/src/lib/aoc.lua b/src/lib/aoc.lua index 73d8028..1290434 100644 --- a/src/lib/aoc.lua +++ b/src/lib/aoc.lua @@ -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 diff --git a/src/lib/days.lua b/src/lib/days.lua index f102b19..21410fe 100644 --- a/src/lib/days.lua +++ b/src/lib/days.lua @@ -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") diff --git a/src/lib/utils.lua b/src/lib/utils.lua index d990232..65bff2b 100644 --- a/src/lib/utils.lua +++ b/src/lib/utils.lua @@ -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