Graderpractice for programmers

273387 Swift - Functions

Awaiting submission
Write a function which takes 1 String parameter and returns "Pleased to meet you X." where X is the parameter value. If the value of the parameter is "" (empty string) then return "I do not know you.".

Use the following code as a template:
// TODO: write your greetAndMeet function here

let input = readLine() ?? ""
let output = greetAndMeet(name: input)
print(output)
Awaiting submission
Write a function called square that takes an Int parameter and returns the square of that number.

Use the following code as a template:
// TODO: write your function here

let inputString = readLine() ?? ""
let input = Int(inputString) ?? 0
let output: Int = square(x: input)
print("\(input) * \(input) = \(output)")
Awaiting submission
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)
Awaiting submission
Write a function that takes an array of strings and counts how many start with a vowel (a, e, i, o, u).

Use the following code as a template:
import Foundation

// TODO: write your function here

let inputString = readLine() ?? ""
let input: [String] = inputString.components(separatedBy: ",")
let result: Int = countStartVowels(list: input)
print(result)