Attendance register
EasyOnline Assessment
Find the students whose term attendance has fallen below a threshold.
A register is a string "Name:CODES". CODES has one character per class session, in order:
Ppresent: the student attended.Llate: the student attended, except that every third late of the term (the 3rd, 6th, 9th, ...) counts as an absence instead.Aabsent: the student did not attend.Eexcused: the session is skipped entirely and counts neither for nor against the student.
Sessions that count are all sessions except the E ones. A student's attendance percentage is attended * 100 // counted (rounded down). If no sessions count (no sessions yet, or all excused), the percentage is 100.
Return every student whose percentage is strictly below threshold.
Input: registers, a list of strings in the format above, and threshold, an integer.
Output: a list of [name, percentage] pairs, ordered by percentage ascending, then by name in plain alphabetical (code point) order.
Example 1
- Input:
- [["Ana:PPLEPL","Ben:PAL","Cat:PPPP"],75]
- Output:
- [["Ben",66]]
- Explanation
- Ana has 5 sessions that count (the E is skipped): P, P, L, P, L. Her two lates are fine, so she attended 5 of 5 = 100%. Ben has P, A, L: 2 of 3 = 66%. Cat is at 100%. Only Ben is under 75.
Example 2
- Input:
- [["Cy:LLLLLL","Dee:EEE","Eli:","Flo:PPAA"],70]
- Output:
- [["Flo",50],["Cy",66]]
- Explanation
- Cy has six lates. The 3rd and 6th each count as an absence, so 4 of 6 attended = 66%. Dee has only excused sessions, so nothing counts against her and she is at 100%; Eli has no sessions yet, also 100%. Flo attended 2 of 4 = 50%. Under 70: Flo (50) then Cy (66).
Example 3
- Input:
- [["Hal:PALPA","Gus:AP","Fay:AAPP","Ivy:PPPP"],80]
- Output:
- [["Fay",50],["Gus",50],["Hal",60]]
- Explanation
- Hal has P, A, L, P, A: 3 of 5 = 60%. Gus is at 50% and Fay at 50%, so the tie is broken alphabetically (Fay first). Ivy is at 100% and is not listed.
Constraints
0 <= registers.length <= 60- Each register is
"Name:CODES"; names are 1 to 12 letters,CODEShas 0 to 60 characters, each one ofP,L,A,E - Names are unique
0 <= threshold <= 101