#!/usr/bin/lua
local r = 56
local q = r / 2
local border = (function ()
return function (x, z)
return (3 == x or 3 == r - x) and (
z < q + 7 and 3 == z % 7 or
z > q and 3 == (r - z) % 7)
end
end)()
local torch = (function ()
local h = math.sqrt(85) -- 6 * 6 + 7 * 7 -- hypotenuse
return function (x, z, sx, sz)
x, z = x + sx, z + sz
x, z = (7 * x - 6 * z) / h, (6 * x + 7 * z) / h
return 0.5 > x % h and 0.5 > z % h
end
end)()
local min, max = 1000, 0
for zs = 0, 7 do for xs = 0, 7 do
local total = 0
for z = 0, r do
for x = 0, r do
if (border(x, z) or border(z, x) or torch(x, z, xs, zs)) then
total = total + 1
end
end
end
if min > total then min = total end
if max < total then max = total end
print("xs: "..xs..",", "zs: "..zs..",", "total: "..total)
end end
print("max: "..max..",", "min: "..min)