Your question is Test Color Setting Functionality. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Figma Design applies color updates to canvas nodes in order. Implement a function that validates and applies each requested color change, preserving the previous color when an update is invalid.
An update is valid only when its node_id exists in nodes and its color is a seven-character hexadecimal string in the form #RRGGBB. Valid colors are stored in lowercase. Multiple valid updates to the same node use last-write-wins behavior. Invalid updates must not change any node and must be recorded by their zero-based position in the updates list.
Implement apply_color_updates(nodes, updates), where nodes is a dictionary mapping nonempty string node IDs to valid color strings, and updates is a list of dictionaries with string fields node_id and color.
Return a dictionary with:
colors: the final node-to-color dictionaryrejected: a list of indices for invalid updates, in ascending orderdef apply_color_updates(nodes, updates):