This commit is contained in:
2024-12-12 14:36:30 -08:00
parent cd945d2456
commit 46b5602afb
5 changed files with 36 additions and 0 deletions

8
day03/d03p1.swift Normal file
View File

@@ -0,0 +1,8 @@
import Foundation
let answer = try String(contentsOfFile: CommandLine.arguments[1])
.matches(of: try Regex(#"mul\(([0-9]+),([0-9]+)\)"#))
.map { m in (Int(m.output[1].substring!), Int(m.output[2].substring!)) }
.map { a, b in a! * b! }
.reduce(0, +)
print(answer)