Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- // Complete the countApplesAndOranges function below.
- func countApplesAndOranges(s: Int, t: Int, a: Int, b: Int, apples: [Int], oranges: [Int]) -> Void {
- var countOfApplesOnSamHouse = 0
- var countOfOrangesOnSamHouse = 0
- for i in 0 ..< apples.count {
- let position = a + apples[i]
- if position >= s && position <= t {
- countOfApplesOnSamHouse = countOfApplesOnSamHouse + 1
- }
- }
- for i in 0 ..< oranges.count {
- let position = b + oranges[i]
- if position >= s && position <= t {
- countOfOrangesOnSamHouse = countOfOrangesOnSamHouse + 1
- }
- }
- print("\(countOfApplesOnSamHouse)\n\(countOfOrangesOnSamHouse)")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement