Fixed Day6 second star and setup functions to make loading of file easier
This commit is contained in:
28
2025/functions.lua
Normal file
28
2025/functions.lua
Normal 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
|
||||
Reference in New Issue
Block a user