This problem is part of our Ada Lovelace Day celebration.
It is for practice only and will NOT count towards your grade!
(just have fun and use it to improve your skills: there is no submission deadline!)
In this problem you should submit a function as described. Inside the function do not print anything that was not asked!
The name of the .py source file you submit to Mooshak should NOT start with a digit (you will get an error if you submit it like that).
Joy Buolamwini is a computer scientist known for exposing bias in artificial intelligence.
She is also the founder of the Algorithmic Justice League, an organization that studies and challenges harmful uses of automated systems.
While working at MIT, Joy noticed that face-detection software struggled to detect her darker-skinned face.
However, the software detected a white mask that she wore...
Joy is testing a face-detection system under different conditions.
She needs your help to identify the people whose faces the system repeatedly fails to detect.
Implement the function find_failures(tests, threshold), which takes a a list of lists (matrix tests) and an integer threshold, and returns a list of people cases where a facial recognition system fails.
The details of the problem are as follows:
For example:
tests = [
[1, 0, 1, 0, 0],
[1, 0, 0, 0, 1],
[0, 1, 1, 0, 0],
[1, 0, 1, 0, 0]
]
contains:
The function must return a list with the numbers of the people whose number of failures is greater than or equal to threshold ("flagged" people).
People must be ordered by failure count, from highest to lowest:
The following limits are guaranteed in all the test cases that will be given to your program:
Let t be the number of tests and p be the number of people, used in tests (a matrix of t rows and p columns):
| 1 ≤ t ≤ 100 | number of tests | |
| 1 ≤ p ≤ 100 | number of people | |
| 1 ≤ threshold ≤ t | minimum number of failures required | |
| Every row contains exactly p entries | ||
| Every entry is an integer in {0, 1} |
| Example Function Calls 1 | Example Output 1 |
tests = [
[1, 0, 1, 0, 0],
[1, 0, 0, 0, 1],
[0, 1, 1, 0, 0],
[1, 0, 1, 0, 0]
]
print(find_failures(tests, 2))
|
[4, 2, 5] |
| Example Function Calls 2 | Example Output 2 |
tests = [
[0, 1, 0],
[1, 0, 0],
[0, 1, 1]
]
print(find_failures(tests, 2))
print(find_failures(tests, 3))
|
[1, 3] [] |
People 1 and 3 qualify when the threshold is 2, and nobody qualifies when it is 3.
| Example Function Calls 3 | Example Output 3 |
tests = [
[0, 0, 0],
[0, 0, 0]
]
print(find_failures(tests, 2))
|
[1, 2, 3] |
Everyone has two failures, so person numbers determine the order.