A gateway writes one access-log entry per line in this exact shape:
IP - - [TIMESTAMP] "METHOD PATH PROTOCOL" STATUS BYTES
where the request line is wrapped in double quotes and contains the method, the path, and the protocol separated by single spaces; STATUS is a 3-digit HTTP status code (100 to 599); and BYTES is a non-negative integer. The IP, TIMESTAMP, PATH, and other fields never contain a double quote, and the timestamp contains no spaces.
For each entry, take the status code and classify it by its leading digit: class 1 is 100-199, class 2 is 200-299, class 3 is 300-399, class 4 is 400-499, class 5 is 500-599. Report how many entries fall in each class.
Line 1: an integer n, the number of log entries.
Next n lines: one log entry each, in the format above.
A single line with five space-separated integers: the counts for classes 1xx, 2xx, 3xx, 4xx, and 5xx, in that order.
Example 1
Input
2 192.168.0.1 - - [10/Oct/2029:13:55:36] "GET /index.html HTTP/1.1" 200 1024 10.0.0.5 - - [10/Oct/2029:13:56:01] "POST /login HTTP/1.1" 302 512
Expected
0 1 1 0 0
Explanation
The first entry has status 200 (class 2xx) and the second 302 (class 3xx). Counts by class 1..5 are 0 1 1 0 0.
Example 2
Input
1 127.0.0.1 - - [10/Oct/2029:14:00:00] "GET / HTTP/1.0" 404 0
Expected
0 0 0 1 0
Explanation
A single entry with status 404 (class 4xx), so the counts are 0 0 0 1 0.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →