AoC/common.swift

19 lines
397 B
Swift
Raw Normal View History

2021-12-12 11:21:58 +01:00
protocol Puzzle {
mutating func run()
init()
}
extension Puzzle {
static func main() {
var instance = Self()
instance.run()
}
}
extension RangeReplaceableCollection {
mutating func removeFirst(where predicate: (Element) -> Bool) -> Element? {
guard let index = firstIndex(where: predicate) else { return nil }
return remove(at: index)
}
}