-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay04.swift
More file actions
28 lines (24 loc) · 743 Bytes
/
Day04.swift
File metadata and controls
28 lines (24 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import AOCCore
import Foundation
struct Day04: Day {
let title = "Printing Department"
var rawInput: String?
func part1() throws -> Int {
let diagram = input().lines.map(\.characters)
let directions: [Direction] = [.upLeft, .up, .upRight, .left, .right, .downLeft, .down, .downRight]
return diagram.indices
.flatMap { y in
diagram[y].indices.map { x in Point(y: y, x: x) }
}
.filter { diagram[$0] == "@" }
.filter { point in
directions
.filter { diagram[point.offset($0)] == "@" }
.count < 4
}
.count
}
func part2() throws -> Int {
-1
}
}