#!/usr/bin/env perl6
 
my %grade = "grades.txt".IO.lines.map: {
m:s/^ (\w+) (<[A..F]><[+-]>?) $/ or die "Can't parse line '$_'";
~$0 => ~$1
};
 
say "Zsófia's grade: %grade<Zsófia>";
 
say "List of students with a failing grade:";
say " " ~ %grade.grep(*.value ge "E")».key.join(', ');
 
say "Distribution of grades by letter:";
say " {.key}: {+.value} student{"s" if .value != 1}"
for %grade.classify(*.value.comb[0]).sort(*.key); 