Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
619 B · 34 lines
Lua
at main
1234567891011121314151617181920212223242526272829303132333435local grid = {}
local _grid = {}
function grid.init(value) for x = 0, 999 do if type(_grid[x]) ~= "table" then _grid[x] = {} end for y = 0, 999 do _grid[x][y] = value end endend
function grid.apply(func, startx, endx, starty, endy) for x = startx, endx do for y = starty, endy do _grid[x][y] = func(_grid[x][y]) end endend
function grid.accum(start, func) local result = start
for x = 0, 999 do for y = 0, 999 do result = func(result, _grid[x][y]) end end
return resultend
return grid