import Foundation let input = loadData(day: 11) enum Spot: Equatable { case empty case occupied case floor } typealias Map = [[Spot]] var map: Map = [] input.enumerateLines { (line, _) in map.append(line.map { switch $0 { case ".": return .floor case "#": return .occupied case "L": return .empty default: fatalError("Invalid input") } }) } let adjacents = [ (-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1) ] /* func step(map: Map) -> Map { var result = map let width = map[0].count for i in 0..= 4: result[i][j] = .empty default: break } } } return result } */ func occupiedInDirection(at pos: (Int, Int), map: Map, direction: (Int, Int)) -> Int { var pos = pos let yRange = 0.. Map { var result = map let width = map[0].count for i in 0..= 5: result[i][j] = .empty default: break } } } return result } while true { let next = step(map: map) if next == map { break } map = next } let totalOccupieds = map.lazy.flatMap { $0 }.filter { $0 == .occupied }.count print(totalOccupieds)