Code for the Advent of Code event
aoc
advent-of-code
1local nice_count = 0
2
3local input = io.open("input.txt", "r")
4
5for line in input:lines("l") do
6 local _, vowels = line:gsub("[aeiou]", "%0")
7 local repeated = line:match("(.)%1")
8 local banned = line:match("ab") or line:match("cd") or line:match("pq") or line:match("xy")
9
10 if vowels >= 3 and repeated and not banned then nice_count = nice_count + 1 end
11end
12
13print(("%d strings are nice"):format(nice_count))
14
15input:close()