PY-23
Build a Unique ID Lookup
Task
Write build_id_lookup(records, required_ids). Each record is a dictionary
with an id value. Build a dictionary that maps every record ID to its record,
and return (lookup, status, details).
Inspect records from left to right. If an ID appears again, it is a duplicate.
Report each ID the first time it is found to be repeated, in that first
repetition order, and return ({}, "duplicate ids", duplicates). Duplicate
checking happens before checking requirements.
If there are no duplicates, inspect required_ids in its supplied order. If a
required ID is absent, collect it and return ({}, "missing ids", missing).
Otherwise return (lookup, "ok", []). For a successful result, lookup
contains the original records in source order as its values. Inputs are valid
lists and dictionaries and must not be changed.
Example
The duplicate result takes priority, so the missing requirement is not reported in the second call.
Your implementation
Edit solution.py and keep this function name and signature:
Return exactly a three-item tuple. On failure the first item is a new empty dictionary. On success the first item maps IDs to the original record objects. Do not print, ask for input, or mutate either input list or any record.