Fix first star of day7
This commit is contained in:
35
2025/Day7/Day7.lua
Normal file
35
2025/Day7/Day7.lua
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
-- Day 7 - Advent of Code 2025 - Bas Grolleman
|
||||||
|
require("functions")
|
||||||
|
|
||||||
|
local input_file = "Day7/test"
|
||||||
|
local input = file_characters_to_table(input_file)
|
||||||
|
|
||||||
|
local rows = tablelength(input)
|
||||||
|
local cols = tablelength(input[1])
|
||||||
|
|
||||||
|
local splits = 0
|
||||||
|
local quantumsplits = 0
|
||||||
|
|
||||||
|
print("Rows " .. rows .. " Cols " .. cols)
|
||||||
|
print(table.concat(input[1]))
|
||||||
|
for R = 2, rows do
|
||||||
|
for C = 1, cols do
|
||||||
|
if input[R][C] == "." then
|
||||||
|
if input[R - 1][C] == "S" or input[R - 1][C] == "|" then
|
||||||
|
input[R][C] = "|"
|
||||||
|
end
|
||||||
|
elseif input[R][C] == "^" and input[R - 1][C] == "|" then
|
||||||
|
if input[R][C - 1] ~= "|" then
|
||||||
|
input[R][C - 1] = "|"
|
||||||
|
end
|
||||||
|
if input[R][C + 1] ~= "|" then
|
||||||
|
quantumsplits = quantumsplits + 2
|
||||||
|
input[R][C + 1] = "|"
|
||||||
|
end
|
||||||
|
splits = splits + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print(table.concat(input[R]) .. " " .. quantumsplits)
|
||||||
|
end
|
||||||
|
print("Total splits " .. splits)
|
||||||
|
print("Total quantumsplits " .. quantumsplits)
|
||||||
142
2025/Day7/full
Normal file
142
2025/Day7/full
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
......................................................................S......................................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
......................................................................^......................................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.....................................................................^.^.....................................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
....................................................................^.^.^....................................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...................................................................^.^...^...................................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..................................................................^.^.^.^.^..................................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.................................................................^.^...^.^.^.................................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
................................................................^.^...^.^.^.^................................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...............................................................^.^.^.^.^.^.^.^...............................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..............................................................^.^.^.^.......^.^..............................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.............................................................^.........^.^.^...^.............................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
............................................................^.....^.^.^.^...^...^............................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...........................................................^.^.^.^.^.^.^.^.^.^.^.^...........................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..........................................................^.^.^.^.^.^...^.^.^.^.^.^..........................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.........................................................^.^.^...^...^...^.^.....^.^.........................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
........................................................^.^.^.^.^.^.^.^...^.^.^.^.^.^........................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.......................................................^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.......................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
......................................................^...^.......^.^.....^.^...^.^.^.^......................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.....................................................^.^.^.......^.^.^.^...^.^.^.^.^.^.^.....................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
....................................................^...^.^...^.^.^.^.^.^.^.^.^.......^.^....................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...................................................^.....^.^.^.^.^.^.^.^.^.^...^.^...^...^...................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..................................................^.^.^...^.....^.^.^.^.^...^.^.^.^.......^..................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.................................................^.^.^.^...^.^.^...^.^...^.^.^.^.^.^.^.^...^.................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
................................................^.^...^...^.^.^...^.......^...^.^.^.....^...^................................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...............................................^.^.....^...^...^.^.^.^.^.^...^.^.^.^.^.^.^.^.^...............................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..............................................^.^.^.^...^.....^.^.^...........^.^.^.^.....^...^..............................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.............................................^.^.....^...^.^.^.^.^...^...^.^...^.^.^.^...^.^.^.^.............................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
............................................^.^.^...^.^.^.^.^.^.^...^.^...^.^.^...^.^.^.^.^.....^............................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...........................................^.......^...^.^.^.^.^.^.^...^.^...^.^.^.....^.^.^.^.^.^...........................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..........................................^.^.^.^.......^...^.....^.^.^.^...^.^...^.^.^.......^.^.^..........................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.........................................^.^.^...^.^...^.^.^...^.^.^.^.^.....^.^...^.....^.^.^.^.^.^.........................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
........................................^.^.^.^...^.^.^.^.^.^.......^...^.^.^.....^.^.....^.^...^.^.^........................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.......................................^.^.^.^.^.^.^.......^.^.^.^...^...^...^.^.^.^...^.^.^.^.......^.......................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
......................................^.^.^.^.^...^...^.^.^.^.^...^...^...^.^...^.^.....^.^.^.^...^.^.^......................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.....................................^.^.....^...^.^...^.^.^.^.........^.^...^.^.^.^.....^.^.^.^.^...^.^.....................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
....................................^...^.^.^.^...^...^...^.^.^.^.^.^.^...^.^.^.^.^...^.........^...^.^.^....................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...................................^.....^.^...^.^.^...^.^...^.^.^.^.^.^...^...^.....^.^.^.^.^.^.....^.^.^...................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..................................^.^.^...^.^.^.^...^.^.^...^.^...^.^.........^.^.^.^...^.....^...^.....^.^..................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.................................^.^.^.^.^.^.....^.^.^.^.^...^.^.^.^.^...^...^.....^.......^.^.^.^.^...^.^.^.................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
................................^...^...^.^...^...^.^.^.^.^.^...^.^...^.^.^.^.^.^.^.^...^.^...^.^.^...^.^.^.^................................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...............................^.^.^.^.^.^.^.....^.^.^.^.......^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^.^...............................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..............................^.^.^.....^.^...^.^.^.......^.^.^.^.^...^.^.^...^.^.^.^.^.^.^.^...^.^.^.........^..............................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.............................^...^...^...^.....^.^...^.^.^.^.......^.^.^...^.^...^.^.^.....^.^.^...^.^.^...^.^.^.............................
|
||||||
|
.............................................................................................................................................
|
||||||
|
............................^.^.^.^.....^...^...^.^.^...^.^...^...^.^...^.......^.^.^.^.^.^...^.^.^.^.^.^...^.^.^............................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...........................^...^.^.^.^.^.^.^.^.....^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^...^...^.^.^.^.^.^...^.^...........................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..........................^.^.^.^...^.^.^.^...^.^...^.^.^...^.^.^.^.^.^.^.^...^.^.^.^.^...^.^.....^...^.^...^.^...^..........................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.........................^.....^.......^.^.^.^.^.....^.^.^.^...^.^...^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.........................
|
||||||
|
.............................................................................................................................................
|
||||||
|
........................^.^.^.^.^.^.^.^.^.^.^.^.......^.....^...^.^.^...^.^.....^.^.......^.^.^.^.^.^.....^.^.....^.^........................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.......................^...^.^.^.^.....^.^.^.^.......^.^...^.^.....^...^.......^...^.^...^.^.^.^.^.^.^.^.^.^...^.^.^.^.......................
|
||||||
|
.............................................................................................................................................
|
||||||
|
......................^.....^.^.^.^.^.^...^.^.^.^...^.....^.^.^.^...^...^.^.^.^.^.^...^.....^.^.^.^...^.^...^...^.^.^.^......................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.....................^.....^.^...^.....^.^.^...^.^...^.^.^...^.^.^.^...^.^...^...^.....^.^...^...^.^.^.^.^.^...^.^.^.^.^.....................
|
||||||
|
.............................................................................................................................................
|
||||||
|
....................^.^.......^.^.....^.^.....^.^.^.^.^.^.^.......^.^...^...^...^.....^.^.^.^.....^...^.^.^.^.^.^.....^.^....................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...................^.^.^.^.^.^.^.^.^...^.^.^.^.^...^.^.^.^.^.......^.^.^.^.^...^.^.^.^.^...^.^.^.^...^.^.^.^.^.^.....^.^.^...................
|
||||||
|
.............................................................................................................................................
|
||||||
|
..................^.^.^.^.....^.^.^...^.^.^.^.^...^.^...^...^.^.^.^.^.....^.^.....^.^.^.^...^...^.^...^...^.^.^...^.^...^.^..................
|
||||||
|
.............................................................................................................................................
|
||||||
|
.................^.^.^.^.^.^...^...^...^.^.^.^.^.....^...^.^.^.^.^.^...^.^.^...^.^.^...^.^...^...^...^.^.....^.^.^.^...^.^.^.................
|
||||||
|
.............................................................................................................................................
|
||||||
|
................^.....^...^.^.^.^.^...^.^.^.^...^.^...^.^.^.......^.^.^.....^.^.^.^.^.^...^...^.^...^.^.....^.^.^.^.^.^.^.^.^................
|
||||||
|
.............................................................................................................................................
|
||||||
|
...............^...^.^.^...^.^.......^.^...^.^...^.^...^.....^...^.^.^.^...^...^.^.^.^.^...^...........^.^.^.^.^.^.....^.^.^.^...............
|
||||||
|
.............................................................................................................................................
|
||||||
|
..............^.^.^.....^.^.....^.^.^.^.^...^.^.^.^.^.^.^...^.^.^...^...^.^...^.^.^.^.^.^...^.^.^...^.^.^.^.^.^.^.^.^...^.^.^.^..............
|
||||||
|
.............................................................................................................................................
|
||||||
|
.............^...^.......^.....^.^...^...^.^.^.^.^...^.^...^...^.^.^...^.^.^.^.^.^...^.^.^.^.....^.^...^.^.......^.^.^.^...^.^.^.............
|
||||||
|
.............................................................................................................................................
|
||||||
|
............^.^.^.^...^.^...^...^.^.^.^.^.^.^.^.^.^...^...^.^.^.^.^.^.^.^.^...^.^.^.^.....^.^.^.^.^.^.^.^.^.^.^...^...^.^...^.^.^............
|
||||||
|
.............................................................................................................................................
|
||||||
|
...........^.^...^.....^.......^...^.^.....^...^.^.^.^.^.^.^...^.^.^.^.^.^.^...^.^.^...^.^.^.^.^.....^.^.^.^.^.^...^.^.^.^.....^.^...........
|
||||||
|
.............................................................................................................................................
|
||||||
|
..........^.......^...^.....^...^...^.^...^.^...^...^.^.^.^.^.^.^.....^.....^...^.^.^.^.^...^.^.^...^.....^.^.^.^.....^...^.^.....^..........
|
||||||
|
.............................................................................................................................................
|
||||||
|
.........^.......^.^.^.^.^.^.^...^.....^.^.^.^.^.^.^.....^...^.^.^.....^.^...^.^.^...^.^.^.^.^.^.^...^.^...^.^...^...^.^.^...^...^.^.........
|
||||||
|
.............................................................................................................................................
|
||||||
|
........^.^.^.^.....^.^.^.^.......^.^.^...^.......^.....^...^.....^.^.^...^...^.^...^...^.^.^.^.....^.^.....^.^.^.^.^.^.^.^...^.....^........
|
||||||
|
.............................................................................................................................................
|
||||||
|
.......^.^.^.^.^.....^...^.^.....^...^.^.^...^.^.^.^.^.^.^...^.^.^.^.^.^.^...^.^...^.^.^.^.^.^...^.^.^.^.^.^...^.^...^.^.^...^.^.^.^.^.......
|
||||||
|
.............................................................................................................................................
|
||||||
|
......^.^...^.^.....^.^.....^.^.^.....^.^.^.^...^.^...^...^...^...^.^...^.....^.^...^.^.^.^...^.^.^...^.^.^.^...^.^.^.^...^...^.....^.^......
|
||||||
|
.............................................................................................................................................
|
||||||
|
.....^.^.^.^...^.^.^...^.^.....^.^...^.^...^...^.^.^.^...^.^...^...^.^.^.^.....^...^.^.^...^...^.^.^...^.^...^.^.^...^.^.^.^.^.^.^.^.^.^.....
|
||||||
|
.............................................................................................................................................
|
||||||
|
....^...^.^.^.^...^...^.^.^.......^.^...^.^...^.^.^...^.^...^.^.^.^.^.^.^.^.^...^...^.^...^.^.^.^.^.^.^.^...^.^...^...^.^.^...^.^.^.^.^.^....
|
||||||
|
.............................................................................................................................................
|
||||||
|
...^...^.^.^.^.^.^.^.^.^...^.^...^.^.^...^...^.^...^.^.....^...^.^.^.^...^...^.^.^.^.^.^.^...^.^.^...^.^.^.....^...^...^.^.^.^.^.^.^.^.^.^...
|
||||||
|
.............................................................................................................................................
|
||||||
|
..^...^.^.^.^.^.^.^...^.^.^.^.^.^.^...^.^.^.^.^...^...^.^.^.^...^...^.^.....^.^.^...^.^.^.....^...^.^.^.^.^.^...^...^.^.^...^.^.^.^.....^.^..
|
||||||
|
.............................................................................................................................................
|
||||||
|
.^.^.^.^.^.^.^...^...^.^.^.^.^...^.^.^.^.....^...^...^.^.^.^.^.^.....^.....^...^.^.^.^.^.^...^...^.^.^.^...^.^.^...^.^.^...^.......^.^...^.^.
|
||||||
|
.............................................................................................................................................
|
||||||
16
2025/Day7/test
Normal file
16
2025/Day7/test
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
.......S.......
|
||||||
|
...............
|
||||||
|
.......^.......
|
||||||
|
...............
|
||||||
|
......^.^......
|
||||||
|
...............
|
||||||
|
.....^.^.^.....
|
||||||
|
...............
|
||||||
|
....^.^...^....
|
||||||
|
...............
|
||||||
|
...^.^...^.^...
|
||||||
|
...............
|
||||||
|
..^...^.....^..
|
||||||
|
...............
|
||||||
|
.^.^.^.^.^...^.
|
||||||
|
...............
|
||||||
@@ -5,7 +5,7 @@ vim.api.nvim_create_autocmd("BufWritePost", {
|
|||||||
pattern = "*.lua",
|
pattern = "*.lua",
|
||||||
callback = function()
|
callback = function()
|
||||||
local bufnr = 21
|
local bufnr = 21
|
||||||
vim.fn.jobstart({ "lua", "Day6/Day6.lua" }, {
|
vim.fn.jobstart({ "lua", "Day7/Day7.lua" }, {
|
||||||
stdout_buffered = true,
|
stdout_buffered = true,
|
||||||
on_stdout = function(_, data)
|
on_stdout = function(_, data)
|
||||||
if data then
|
if data then
|
||||||
|
|||||||
Reference in New Issue
Block a user