DEV Community

Discussion on: Daily Challenge #87 - Pony Express

Collapse
 
avalander profile image
Avalander

My challenge is writing this is Haskell on the phone without running the code.

calc_riders :: [Int] -> Int
calc_riders = fst . foldl count (1, 0)

count :: (Int, Int) -> Int -> (Int, Int)
count (r, m) x
  | m + x > 100 = (r + 1, m)
  | otherwise   = (r, m + x)