Skip to content

Commit 893d943

Browse files
committed
Implement day 25
1 parent 03cc785 commit 893d943

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

day25/src/day25.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,13 @@ if args.count == 1 {
77
}
88

99
let rawInput = try String(contentsOfFile: args[1], encoding: .utf8)
10-
print("Input: \(rawInput)")
10+
let schematics = rawInput.split(separator: "\n\n")
11+
.map { $0.replacing("\n", with: "") }
12+
.map { $0.reduce(UInt64(0)) { ($0 << 1) | ($1 == "#" ? 1 : 0) } }
13+
14+
let part1 = schematics
15+
.enumerated()
16+
.map { (i, s1) in schematics.dropFirst(i + 1).filter { s2 in s1 & s2 == 0 }.count }
17+
.reduce(0, +)
18+
19+
print("Part 1: \(part1)")

0 commit comments

Comments
 (0)