Forgot to commit the last few days
This commit is contained in:
@@ -33,3 +33,48 @@ for R = 2, rows do
|
||||
end
|
||||
print("Total splits " .. splits)
|
||||
print("Total quantumsplits " .. quantumsplits)
|
||||
|
||||
-- Okay, time to learn how to make a tree node
|
||||
-- Great, I learned how to try a brute force (that will obviously never work)
|
||||
|
||||
function createNode(col)
|
||||
local node = {
|
||||
col = col,
|
||||
childeren = {},
|
||||
}
|
||||
return node
|
||||
end
|
||||
|
||||
local root = createNode(math.ceil(cols / 2))
|
||||
|
||||
local active_nodes = { root }
|
||||
|
||||
for row = 2, rows do
|
||||
for k, n in ipairs(active_nodes) do
|
||||
if next(n.childeren) == nil then
|
||||
if input[row][n.col] == "^" then
|
||||
local a = createNode(n.col - 1)
|
||||
local b = createNode(n.col + 1)
|
||||
table.insert(active_nodes, a)
|
||||
table.insert(active_nodes, b)
|
||||
n.childeren = { a, b }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local gt = 0
|
||||
function count_table(t, indent)
|
||||
indent = indent or ""
|
||||
print(indent .. "c" .. t.col)
|
||||
if next(t.childeren) ~= nil then
|
||||
for k, v in pairs(t.childeren) do
|
||||
count_table(v, indent .. " ")
|
||||
end
|
||||
else
|
||||
gt = gt + 1
|
||||
end
|
||||
end
|
||||
|
||||
count_table(root)
|
||||
print("Grand Total " .. gt)
|
||||
|
||||
Reference in New Issue
Block a user