d03
This commit is contained in:
8
day03/d03p1.swift
Normal file
8
day03/d03p1.swift
Normal 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)
|
Reference in New Issue
Block a user