Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.73 KB | None | 0 0
  1. import Foundation
  2.  
  3. // Complete the countApplesAndOranges function below.
  4. func countApplesAndOranges(s: Int, t: Int, a: Int, b: Int, apples: [Int], oranges: [Int]) -> Void {
  5.     var countOfApplesOnSamHouse = 0
  6.     var countOfOrangesOnSamHouse = 0
  7.    
  8.     for i in 0 ..< apples.count {
  9.         let position = a + apples[i]
  10.         if position >= s && position <= t {
  11.             countOfApplesOnSamHouse = countOfApplesOnSamHouse + 1
  12.         }
  13.     }
  14.    
  15.     for i in 0 ..< oranges.count {
  16.         let position = b + oranges[i]
  17.         if position >= s && position <= t {
  18.             countOfOrangesOnSamHouse = countOfOrangesOnSamHouse + 1
  19.         }
  20.     }
  21.  
  22.     print("\(countOfApplesOnSamHouse)\n\(countOfOrangesOnSamHouse)")
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement