Highest grade per subject

Write codeMedium13 min

Your task

A gradebook logs retakes as rows "student,subject,score" (score a non-negative integer); the same student-subject pair can appear several times. Produce the flattened grade matrix the report card reads: a dictionary keyed by "student.subject" (the two fields joined with a dot) whose value is that pair's HIGHEST score. Example: ["ava,math,80", "ava,math,92", "raj,art,75"] gives {"ava.math": 92, "raj.art": 75}.

Examples

grade_matrix(rows: list[str]) -> dict[str,int]
Example 1
Inputgrade_matrix(["ava,math,80", "ava,math,92", "raj,art,75"])
Output{"ava.math": 92, "raj.art": 75}