Flip the Score Map

In the old data format, the grouping is reversed: points come first, with a list of letters that share that value. The function transform receives legacy_data and converts it into a new dictionary where each key is a lowercase letter and each value is its score. The score keys arrive as strings, so convert them to integers before storing them.

Примеры

Ввод
{"1": ["A", "E", "I", "O", "U"]}
Вывод
{"a": 1, "e": 1, "i": 1, "o": 1, "u": 1}
Ввод
{"1": ["A"], "2": ["D"]}
Вывод
{"a": 1, "d": 2}
Ввод
{"4": ["F", "H"], "8": ["X"]}
Вывод
{"f": 4, "h": 4, "x": 8}

Нужно реализовать

def transform(legacy_data: dict) -> dict:

Теги

dicthashmap
PostgreSQLv16

Itt jelenik meg a kód futtatásának eredménye

Tests7
Visible tests
Rejtett teszt 7

They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.

Focus radio
Paused · SomaFM · Fluid