33 lines
644 B
Lua
Executable File
33 lines
644 B
Lua
Executable File
#!/usr/bin/env lua
|
|
-- I'm feeling lazy.
|
|
local numbers = {}
|
|
|
|
for line in io.lines() do
|
|
table.insert(numbers, tonumber(line))
|
|
end
|
|
|
|
local function part1()
|
|
for _, x in ipairs(numbers) do
|
|
for _, y in ipairs(numbers) do
|
|
if x + y == 2020 then
|
|
return x * y
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
local function part2()
|
|
for _, x in ipairs(numbers) do
|
|
for _, y in ipairs(numbers) do
|
|
for _, z in ipairs(numbers) do
|
|
if x + y + z == 2020 then
|
|
return x * y * z
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
print(part1())
|
|
print(part2())
|