day 22 part 2
This commit is contained in:
parent
6ef26926ad
commit
9c96d30ea6
@ -57,39 +57,37 @@ local function cut3d(a, b)
|
|||||||
}
|
}
|
||||||
for _, combo in pairs(nobscombos) do
|
for _, combo in pairs(nobscombos) do
|
||||||
local xs, ys, zs = unpack(combo)
|
local xs, ys, zs = unpack(combo)
|
||||||
for _, x in pairs(xs) do
|
for _, x in pairs(xs) do if x.s < x.e then
|
||||||
for _, y in pairs(ys) do
|
for _, y in pairs(ys) do if y.s < y.e then
|
||||||
for _, z in pairs(zs) do
|
for _, z in pairs(zs) do if z.s < z.e then
|
||||||
table.insert(aparts, { b = a.b, x=x, y=y, z=z })
|
table.insert(aparts, { b = a.b, x=x, y=y, z=z })
|
||||||
end
|
end end
|
||||||
end
|
end end
|
||||||
end
|
end end
|
||||||
end
|
end
|
||||||
|
|
||||||
return aparts
|
return aparts
|
||||||
end
|
end
|
||||||
|
|
||||||
local fixed = { ranges[1] }
|
local count = 0
|
||||||
table.remove(ranges, 1)
|
for i = 1, #ranges do
|
||||||
for _, range in pairs(ranges) do
|
if ranges[i].b then
|
||||||
|
print(i, os.clock())
|
||||||
|
local fixed = { ranges[i] }
|
||||||
|
for j = i + 1, #ranges do
|
||||||
local newfixed = {}
|
local newfixed = {}
|
||||||
--printtable(range)
|
|
||||||
if range.b then
|
|
||||||
table.insert(newfixed, range)
|
|
||||||
end
|
|
||||||
for _, f in pairs(fixed) do
|
for _, f in pairs(fixed) do
|
||||||
for _, fpart in pairs(cut3d(f, range)) do
|
for _, fpart in pairs(cut3d(f, ranges[j])) do
|
||||||
--io.write(" ")
|
|
||||||
--printtable(fpart)
|
|
||||||
table.insert(newfixed, fpart)
|
table.insert(newfixed, fpart)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
fixed = newfixed
|
fixed = newfixed
|
||||||
end
|
end
|
||||||
|
for _, r in pairs(fixed) do
|
||||||
local count = 0
|
|
||||||
for _, r in pairs(fixed) do
|
|
||||||
-- printtable(r)
|
-- printtable(r)
|
||||||
count = count + (r.x.e - r.x.s)*(r.y.e - r.y.s)*(r.z.e - r.z.s)
|
count = count + (r.x.e - r.x.s)*(r.y.e - r.y.s)*(r.z.e - r.z.s)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
io.write(string.format("%d\n", count))
|
io.write(string.format("%d\n", count))
|
||||||
|
Loading…
Reference in New Issue
Block a user