adventofcode-2021/day17/part1.lua
Felix Van der Jeugt 6005fb089d
day 17
2021-12-17 10:03:15 +01:00

20 lines
395 B
Lua
Executable File

#!/usr/bin/env luajit
require("utils")
local xmin, xmax, ymin, ymax = string.match(io.open(arg[3]):read("*a"), "target area: x=(.*)%.%.(.*), y=(.*)%.%.(.*)")
xmin, xmax, ymin, ymax = tonumber(xmin), tonumber(xmax), tonumber(ymin), tonumber(ymax)
local maxdy = 0
if ymax > 0 then
maxdy = ymax
end
if ymin < 0 then
if -ymin - 1 > maxdy then
maxdy = -ymin - 1
end
end
print(euler(maxdy))