Build a Unique Assignment
Give every position a different allowed value, undoing choices that lead to a dead end.
The problem
Implement smallest_unique_assignment(options). options[i] is the list of integers allowed at position i. Pick one value for every position so that no value is used twice. Among all valid picks, return the one that is smallest in dictionary order: compare the values at position 0 first, then position 1, and so on. If no valid pick exists, return []. An empty options list returns []. For example, with [[1, 2], [1], [2, 3]] position 1 can only be 1, so position 0 must take 2, and the answer is [2, 1, 3].
Starter code
def smallest_unique_assignment(options):
passPublic examples
options = [[1, 2], [1], [2, 3]]gives[2, 1, 3]options = [[1], [1]]gives[]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
