Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Latest commit

 

History

History
12 lines (10 loc) · 353 Bytes

PlusMinus.md

File metadata and controls

12 lines (10 loc) · 353 Bytes

Plus Minus

func plusMinus(arr: [Int]) -> Void {
    let positives = Double(arr.filter {$0 > 0}.count)
    let negatives = Double(arr.filter {$0 < 0}.count)
    let zeros = Double(arr.filter {$0 == 0}.count)
    let arrayCount = Double(arr.count)
    
    print("\(positives/arrayCount)\n\(negatives/arrayCount)\n\(zeros/arrayCount)")
}