Reference solution
The shape we check against. Any implementation that passes the assertions is valid — this one favours clarity.
def common_and_unique(a, b):
sa, sb = set(a), set(b)
return (sorted(sa & sb), sorted(sa - sb))
Write common_and_unique(a, b) returning a tuple (common, only_a) where common is a sorted list of values in both lists and only_a is a sorted list of values only in a.
hint ladder
Inspect a chained expression (df.query(…).groupby(…).agg(…)) to see the shape and preview after each step.
Run your code to see its output, or check your solution to grade it.
Reference solution
The shape we check against. Any implementation that passes the assertions is valid — this one favours clarity.
def common_and_unique(a, b):
sa, sb = set(a), set(b)
return (sorted(sa & sb), sorted(sa - sb))
Code is blurred until you solve this problem — the reasoning stays readable.