Compare commits

..

3 Commits

Author SHA1 Message Date
efd650f1cd Test autorunner on Day4 2025-12-05 07:59:37 +01:00
05c49abca3 Day5 First puzzle get 2025-12-05 07:59:09 +01:00
6b90ca82e3 Create autorun script for neovim 2025-12-05 07:58:53 +01:00
5 changed files with 1254 additions and 1 deletions

View File

@@ -10,7 +10,7 @@
--
--
--local input_file = "test"
local input_file = "full"
local input_file = "Day4/full"
local warehouse = {}
local row = 0

46
2025/Day5/Day5.lua Normal file
View File

@@ -0,0 +1,46 @@
-- Using Autorun now
print("Starting Day 5...")
local input_file = "Day5/full"
local Freshness = {
Range = {},
}
function Freshness.add(R)
local S, E = string.match(R, "(%d+)-(%d+)")
local Set = { tonumber(S), tonumber(E) }
table.insert(Freshness.Range, Set)
end
function Freshness.show()
for k, v in pairs(Freshness.Range) do
print(string.format("%d-%d", v[1], v[2]))
end
end
function Freshness.check(value)
cv = tonumber(value)
for k, v in pairs(Freshness.Range) do
if cv >= v[1] and cv <= v[2] then
return true
end
end
return false
end
local InputMode = true
local FreshCounter = 0
for line in io.lines(input_file) do
if line == "" then
InputMode = false
elseif InputMode then
Freshness.add(line)
else
if Freshness.check(line) then
print("Fresh Item " .. line)
FreshCounter = FreshCounter + 1
end
end
end
print("Found Fresh Ingredients " .. FreshCounter)

1174
2025/Day5/full Normal file

File diff suppressed because it is too large Load Diff

11
2025/Day5/test Normal file
View File

@@ -0,0 +1,11 @@
3-5
10-14
16-20
12-18
1
5
8
11
17
32

22
2025/autorun.lua Normal file
View File

@@ -0,0 +1,22 @@
-- Use this to get the buffer ID where you want the output
-- echo nvim_get_current_buf()
vim.api.nvim_create_autocmd("BufWritePost", {
group = vim.api.nvim_create_augroup("AutoRunCode", { clear = true }),
pattern = "*.lua",
callback = function()
local bufnr = 21
vim.fn.jobstart({ "lua", "Day5/Day5.lua" }, {
stdout_buffered = true,
on_stdout = function(_, data)
if data then
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, data)
end
end,
on_stderr = function(_, data)
if data then
vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, data)
end
end,
})
end,
})