We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 03cc785 commit 893d943Copy full SHA for 893d943
day25/src/day25.swift
@@ -7,4 +7,13 @@ if args.count == 1 {
7
}
8
9
let rawInput = try String(contentsOfFile: args[1], encoding: .utf8)
10
-print("Input: \(rawInput)")
+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