Code for the Advent of Code event
aoc
advent-of-code
1local input = io.open("input.txt", "r")
2
3local floor = 0
4
5local char
6
7local position = 0
8
9repeat
10 char = input:read(1)
11 position = position + 1
12 if char == "(" then
13 floor = floor + 1
14 elseif char == ")" then
15 floor = floor - 1
16 end
17until not char or floor == -1
18
19print("Reached floor -1 at position " .. position)
20
21input:close()