Build an answer-sheet score table
You are given the answer key string K of a test.
The questions are numbered 1 to L (L is the length of K), and the i-th character of K is the answer to question i.
You are given the answer sheets of n students.
A sheet is a string of A to E and .
(skipped), with length at least 1 and at most L.
If a sheet is shorter than L, the missing questions at the end count as skipped.
A correct answer scores 3 points, a wrong one -1 point, and a skipped one 0 points.
Instead of loops, build and print the following with list comprehensions, generator expressions and built-in tools such as the zip family, enumerate, sorted and itertools.groupby.
1) For each student in input order, print one line "name score correct wrong skipped".
2) Group students with the same score, and print one line "score name1 name2 ..." per group, from the highest score.
Within a group, write the names in input order.
3) Print, on one line separated by spaces from the smallest, the numbers of the questions that the most students got wrong.
If nobody got any question wrong, print -.
- Input
- First line K (uppercase A to E, 1 ≤ L ≤ 100).
Second line n (1 ≤ n ≤ 1000).
Then n lines "name sheet".
Names are 1 to 10 lowercase letters and digits, all different. - Output
- 1) n lines, 2) one line per different score, 3) one line
ABCDE 4 mina ABCDD joon AB sora .BCEA ted EBC
mina 11 4 1 0 joon 6 2 0 3 sora 4 2 2 1 ted 5 2 1 2 11 mina 6 joon 5 ted 4 sora 5
CAB 3 amy CAB bo C.B cy CAB
amy 9 3 0 0 bo 6 2 0 1 cy 9 3 0 0 9 amy cy 6 bo -