Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
611 B · 38 lines
Lua
at main
123456789101112131415161718192021222324252627282930313233343536373839local input = io.open("input.txt", "r")
local map = {}
local deliveries = 1
local x = 0local y = 0
map[x] = {}map[x][y] = true
local char
repeat char = input:read(1)
if char == "^" then y = y + 1 elseif char == "v" then y = y - 1 elseif char == "<" then x = x - 1 elseif char == ">" then x = x + 1 end
if type(map[x]) ~= "table" then map[x] = {} end
if not map[x][y] then deliveries = deliveries + 1 map[x][y] = true enduntil not char
print("Delivered at least once to " .. deliveries .. " houses")
input:close()