Skip to content
Permalink
46162105ed
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
15 lines (14 sloc) 418 Bytes
import Foundation
struct Part2 {
static func run(target: Int, numbers: [Int]) -> Int? {
for runlen in 2..<numbers.count-1 {
for start in 0..<numbers.count-runlen {
let subset = numbers[start..<start+runlen]
if subset.sum() == target {
return subset.min()! + subset.max()!
}
}
}
return nil
}
}