Solution

ID: past-exam-of-the-mathematical-and-computational-biology-course-of-the-university-of-cambridge/2025/paper-1/1/c/solution

It filters the first list by membership in the second list, retaining the order and all repetitions of qualifying entries in the first list. For example, mystery3([3, 1, 3, 2], [3, 4]) returns [3, 3]. Thus it is related to set intersection, but its result is a list and does not discard repeated elements.

New to topics? Read the docs here!