Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func countApplesAndOranges(s: Int, t: Int, a: Int, b: Int, apples: [Int], oranges: [Int]) -> Void {
- func isFruitOnSamHouse(position: Int) -> Bool {
- return position >= s && position <= t
- }
- let applesOnSamHouse = apples.map { (element) -> Int in
- element + a}.filter(isFruitOnSamHouse)
- let orangesOnSamHouse = oranges.map { (element) -> Int in
- element + b}.filter(isFruitOnSamHouse)
- print("\(applesOnSamHouse.count)\n\(orangesOnSamHouse.count)")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement