import Foundation func readInput(_ filePath: String) throws -> [[Character]] { let content = try String(contentsOfFile: filePath, encoding: .ascii) return content.split(separator: "\n").map(Array.init) } let MAS: (Character, Character, Character) = ("M", "A", "S") func dX(_ map: [[Character]], _ i: Int, _ j: Int) -> Bool { return ((map[i-1][j-1], map[i][j], map[i+1][j+1]) == MAS || (map[i+1][j+1], map[i][j], map[i-1][j-1]) == MAS) && ((map[i-1][j+1], map[i][j], map[i+1][j-1]) == MAS || (map[i+1][j-1], map[i][j], map[i-1][j+1]) == MAS) } let input = try readInput(CommandLine.arguments[1]) let answer = (1..