day 1
This commit is contained in:
parent
81b5ce427a
commit
bc39d1bc3d
File diff suppressed because it is too large
Load Diff
|
@ -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);
|
Loading…
Reference in New Issue