Students take an exam, and each result is a percentage score. Classify every result into one of three bands and count how many results fall into each band.
Function Signature
def count_result_bands(results: list[int]) -> list[int]:
Rules
-
A result below 50 is
Failed
:
score < 50
.
-
A result from 50 to 80, both inclusive, is
Passed without Honors
:
50 <= score <= 80
.
-
A result above 80 is
Passed with Honors
:
score > 80
.
-
Return a list of exactly three integers in this order:
[failed, passed_without_honors, passed_with_honors]
.
-
Every result is counted in exactly one band, so the three counts sum to
len(results)
.
Constraints
-
1 <= len(results) <= 100
-
Each
results[K]
is an integer with
0 <= results[K] <= 100
. The report states the band limits as percentages without giving the score range; this version fixes it to whole percentages from 0 to 100.
Examples
Example 1
Input: results = [50, 80, 81, 99, 30, 77, 67]
Output: [1, 4, 2]
30 is the only failed result. 50 and 80 sit exactly on the band limits and, together with 77 and 67, pass without honors. 81 and 99 pass with honors.
Example 2
Input: results = [30, 30, 49]
Output: [3, 0, 0]
Example 3
Input: results = [0, 100]
Output: [1, 0, 1]