Skip to content
loading...

re: Daily Challenge #87 - Pony Express VIEW POST

FULL DISCUSSION
 

This is a Swift solution:

func riders(stations: [Int]) -> Int {
    var n = 1
    var d = 0

    for distance in stations {
        if (d + distance > 100) {
            n += 1
            d = distance
        } else {
            d += distance
        }
    }

    return n
}
code of conduct - report abuse