Skip to content

2019-3: Grade Distribution

The school's administrative department wants to publish some simple statistics. Given a non-empty character vector of single-letter grades, produce a 3-column, 5-row, alphabetically-sorted matrix of each grade, the number of occurrences of that grade, and the percentage (rounded to 1 decimal position) of the total number of occurrences of that grade. The table should have a row for each grade even if there are no occurrences of a grade.

Note: due to rounding the last column might not total 100%.

💡 Hint: The key operator could be useful for this problem.

Examples:

      (your_function) 9 3 8 4 7/'DABFC'
A 3  9.7
B 8 25.8
C 7 22.6
D 9 29  
F 4 12.9

      (your_function) 20⍴'ABC'
A 7 35
B 7 35
C 6 30
D 0  0
F 0  0

      (your_function) ,'B'
A 0   0
B 1 100
C 0   0
D 0   0
F 0   0
your_function ←

Solutions

Video Thumbnail YouTube

Chat transcript Code on GitHub