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

Hier erscheint das Ergebnis der Codeausführung

Visible tests
1
Input
{"1":["A","E","I","O","U"]}
Expected{"a":1,"e":1,"i":1,"o":1,"u":1}
2
Input
{"1":["A"],"2":["D"]}
Expected{"a":1,"d":2}
3
Input
{"4":["F","H"],"8":["X"]}
Expected{"f":4,"h":4,"x":8}
4
Input
{"10":["Q","Z"]}
Expected{"q":10,"z":10}
5
Input
{}
Expected{}
6
Input
{"2":["D"]}
Expected{"d":2}
Focus radio
Paused · SomaFM · Fluid