Element checking
For the next exercise, you will be given a 2D array of integer values. The each entry in the 2D array represents an age of a person. Your task is to check where the person represented by the array is due to visit the DMV soon. So for each element in the array check if they match the list of criteria below. You must return a corresponding 2D array, 1 if the entry meets all the condition and 0 if the entry does not meet the conditions.
- The person is at least 14
- The person's age ends in 4 or 9
- And the person is not 19
For example, an age array of
[[22, 13, 31, 13], [17, 14, 24, 22]]
will have the output array as
[[0, 0, 0, 0], [0, 1, 1, 0]]
Exercise 3
(2 points)
Write a function
fast_check_elem
with the following parameters:
X
: The list of 2D age array as described above.
The function should return a 2D array with the entries of either 0 or 1 as described above.
You function must run 15 times faster than
slow_check_elem
.