Day5 First puzzle get

This commit is contained in:
2025-12-05 07:59:09 +01:00
parent 6b90ca82e3
commit 05c49abca3
3 changed files with 1231 additions and 0 deletions

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)