Coding Exercises: Arrays
Make sure to write full unit tests for these functions.
1. Count lucky
A number is lucky if it is a multiple of 7 or ends in 7. Write a function that counts the number of lucky numbers in an array of integers.
countLucky({1, 2, 3}) -> 0
countLucky({7, 13, 17}) -> 2
countLucky({107, 207}) -> 2
2. Sum of squares (array)
Write a function that takes a single array of doubles as input, and returns the sum of squares of the values.
sumOfSquares({0}) -> 0
sumOfSquares({1.0, 2.0, 3.0}) -> 14.0
sumOfSquares({2.0, 2.0, 2.0}) -> 12.0
3. Total Z name length
Write a function that takes an array of strings as input, and returns the total length of the strings that start with āzā or āZā.
countZNames({"Dr. Kessner", "Dr. Sands"}) -> 0
countZNames({"Zorro", "zero", "zippy"}) -> 14