#!/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);
IyEvdXNyL2Jpbi9lbnYgcGVybDYKIApteSAlZ3JhZGUgPSAiZ3JhZGVzLnR4dCIuSU8ubGluZXMubWFwOiB7Cm06cy9eIChcdyspICg8W0EuLkZdPjxbKy1dPj8pICQvIG9yIGRpZSAiQ2FuJ3QgcGFyc2UgbGluZSAnJF8nIjsKfiQwID0+IH4kMQp9OwogCnNheSAiWnPDs2ZpYSdzIGdyYWRlOiAlZ3JhZGU8WnPDs2ZpYT4iOwogCnNheSAiTGlzdCBvZiBzdHVkZW50cyB3aXRoIGEgZmFpbGluZyBncmFkZToiOwpzYXkgIiAiIH4gJWdyYWRlLmdyZXAoKi52YWx1ZSBnZSAiRSIpwrsua2V5LmpvaW4oJywgJyk7CiAKc2F5ICJEaXN0cmlidXRpb24gb2YgZ3JhZGVzIGJ5IGxldHRlcjoiOwpzYXkgIiB7LmtleX06IHsrLnZhbHVlfSBzdHVkZW50eyJzIiBpZiAudmFsdWUgIT0gMX0iCmZvciAlZ3JhZGUuY2xhc3NpZnkoKi52YWx1ZS5jb21iWzBdKS5zb3J0KCoua2V5KTsg