Class lists X26369


Statement
 

pdf   zip

html

At EEBE school each student is enrolled in various groups of different subjects. Those enrollment data are saved in a dictionary that associates the ID of each student with the list of groups in which he has enrolled.

The school has to provide each teacher with the list of students enrolled in their groups.

Design a function listas_clase(matr) that, given a dict matr with enrollment data like the one described at the beginning, returns another dictionary that associates each group with the alphabetically sorted list of the IDs of the students enrolled in that group.

Sample session
>>> matr = {'5555E': ['I21', 'SD32', 'MC10'],
...         '2222B': ['I21', 'DCAD11', 'E10'],
...         '4444D': ['I21', 'SD32'],
...         '1111A': ['I21', 'DCAD11', 'MC10'],
...         '3333C': ['I21', 'SD32', 'E10']}
>>> lc = listas_clase(matr)
>>> if lc != {'I21':['1111A','2222B','3333C','4444D','5555E'],
...           'DCAD11': ['1111A','2222B'],
...           'SD32': ['3333C','4444D','5555E'],
...           'MC10': ['1111A','5555E'],
...           'E10': ['2222B','3333C']}:
...     print(lc)
Information
Author
InfBesos
Language
English
Translator
Original language
Spanish
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python