This commit is contained in:
ngoomie 2023-12-02 21:01:21 -07:00
parent 81b5ce427a
commit bc39d1bc3d
2 changed files with 1030 additions and 0 deletions

1000
01/input.txt Normal file

File diff suppressed because it is too large Load Diff

30
01/main.lua Executable file
View File

@ -0,0 +1,30 @@
input = {};
for line in io.lines("./input.txt") do
table.insert(input, line)
end
parsed = {};
for key, value in pairs(input) do
local alphastrip = string.gsub(value, "[%a]", "");
if string.len(alphastrip) == 1 then
local doubled = alphastrip .. alphastrip;
table.insert(parsed, doubled);
elseif string.len(alphastrip) == 2 then
table.insert(parsed, alphastrip);
else
local digitstrip = string.match(alphastrip, "%d", 1) .. string.match(alphastrip, "%d", -1);
table.insert(parsed, digitstrip);
--print(digitstrip);
end
end
result = 0;
for key, value in pairs(parsed) do
result = value + result;
end
print(result);