Fixed Day6 second star and setup functions to make loading of file easier

This commit is contained in:
2025-12-07 09:24:25 +01:00
parent 8270b9ec78
commit d7ec4b9dad
2 changed files with 73 additions and 0 deletions

28
2025/functions.lua Normal file
View File

@@ -0,0 +1,28 @@
function file_lines_to_table(filename)
local file = {}
for line in io.lines(filename) do
table.insert(file, line)
end
return file
end
function file_characters_to_table(filename)
local file = {}
for line in io.lines(filename) do
local lineelements = {}
for I = 1, string.len(line) do
c = string.sub(line, I, I)
table.insert(lineelements, c)
end
table.insert(file, lineelements)
end
return file
end
function tablelength(T)
local count = 0
for _ in pairs(T) do
count = count + 1
end
return count
end