7.6 - Challenges
Create a function for each challenge below. It must match the provided dataflow.
You should test each function fully to ensure it works as expected.
1 - Shortest string
Write a function that will find the shortest strign in an array.
Data flow
IN: string_array
OUT: shortest string
2 - Create array of random numbers
Write a function that will generate an array of specified size and fill it with random numbers (1-10).
Data flow
IN: array_size
OUT: number_array
3 - Average number
Write a function that will calculate the average value from a number array.
Data flow
IN: number_array
OUT: average
4 - Find a target
Write a function that will check if a target word is in an array of strings. It should return a boolean.
Data flow
IN: array, target
OUT: found
5 - Find a person
Write a function that will find the first matching forename in an array of forenames.
If found it should return the full name.
Data flow
IN: forenames, surnames, search_forename
OUT: fullname
6 - Find the difference
Write a function that will find the difference between the highest and lowest number in an array.
Data flow
IN: number_array
OUT: difference
7 - Check if array is positive
Write a function that will check if all numbers in an array are positive. It should return a boolean.
Data flow
IN: number_array
OUT: all_positive
8 - Concatenation
Write a function that will concatenate an array of strings into one string.
Data flow
IN: string_array
OUT: combined_string
9 - Array middle
Write a function that return the middle element of the array.
How will you deal with even array lengths?
Data flow
IN: array
OUT: middle_element
10 - Ascending array
Write a function to check if a number array is in ascending order. It should return a boolean.
Data flow
IN: array
OUT: is_ascending
11 - Unique array
Write a function to check if every number in an array is unique. It should return a boolean.
Data flow
IN: array
OUT: is_unique