Graderpractice for programmers

Back to 273387 Swift - Functions

Are you odd?

Problem

Write a function that takes an Array of Ints and returns true (Bool) if all the numbers are odd.

Use the following code as a template:

import Foundation

// TODO: write your function here

let inputString = readLine() ?? ""
let numbers: [Int] = inputString.components(separatedBy: ",").compactMap { Int($0) }
let result: Bool = isOdd(list: numbers)
print(result)

Examples

Input

1,5,7,21

Output

true

Input

1,4,7

Output

false

Submit your solution

swift