44 lines
838 B
Lua
Executable File
44 lines
838 B
Lua
Executable File
#!/usr/bin/env luajit
|
|
|
|
function readline()
|
|
local x1 = io.read("*n")
|
|
io.read(1) -- ","
|
|
local y1 = io.read("*n")
|
|
io.read(4) -- " -> "
|
|
local x2 = io.read("*n")
|
|
io.read(1) -- ","
|
|
local y2 = io.read("*n")
|
|
io.read("*l") -- "...\n"
|
|
return x1, y1, x2, y2
|
|
end
|
|
|
|
io.input(arg[3])
|
|
local x1, y1, x2, y2 = readline()
|
|
local field = {}
|
|
while x1 ~= nil do
|
|
if x1 == x2 then
|
|
for y = math.min(y1, y2), math.max(y1, y2) do
|
|
local row = field[x1] or {}
|
|
row[y] = (row[y] or 0) + 1
|
|
field[x1] = row
|
|
end
|
|
elseif y1 == y2 then
|
|
for x = math.min(x1, x2), math.max(x1, x2) do
|
|
local row = field[x] or {}
|
|
row[y1] = (row[y1] or 0) + 1
|
|
field[x] = row
|
|
end
|
|
end
|
|
x1, y1, x2, y2 = readline()
|
|
end
|
|
|
|
local count = 0
|
|
for r, row in pairs(field) do
|
|
for c, col in pairs(row) do
|
|
if col >= 2 then
|
|
count = count + 1
|
|
end
|
|
end
|
|
end
|
|
print(count)
|