A small studio logs work as a list of timesheet entries. Each entry is a tuple (person, project, hours); the same person and project can appear in many entries.
Write timesheet(entries) that returns a dictionary with one key per person. The value is a tuple (total_hours, main_project):
total_hoursis everything that person logged, over all projects;main_projectis the project on which that person logged the most hours in total; if several projects tie, take the one that comes first alphabetically.
Return an empty dictionary when there are no entries. The helper work_log(n, seed) returns n random entries.
Examples
Input: entries = [("ana", "web", 3), ("ben", "app", 2.5), ("ana", "app", 1.5),
("ana", "web", 0.5), ("ben", "web", 2.5)]
Output: {"ana": (5.0, "web"), "ben": (5.0, "app")}
Explanation: ana has 3.5 hours on web and 1.5 on app. ben has 2.5 on each,
a tie, and "app" comes before "web".
Input: entries = [("jo", "docs", 2)]
Output: {"jo": (2, "docs")}
Constraints
0 <= len(entries) <= 10**5- hours are positive multiples of
0.25and at most8 - names and projects are non-empty lowercase strings
Goals
- Group values with a dictionary of dictionaries
- Walk a dictionary with .items() and break ties deliberately