A greenhouse's climate-control system arranges its humidity sensors in a rectangular grid, but the daily log a technician pulls from it never states how many rows or columns the grid actually has -- the raw sensor dump is just written out row by row, and the shape has to be recovered by reading it. You receive the dump exactly as captured: one row of sensor readings per line, with the readings on each line separated by single spaces, and every row containing the same number of readings as every other row. Recover and print the number of rows and the number of columns in the grid. If the dump contains no lines at all, report the grid as having 0 rows and 0 columns.
The input is zero or more lines, read until end-of-file. Each line, if present, contains one or more integers separated by single spaces -- the readings for one row of the grid. Every non-empty input has the same number of integers on every line.
Print two integers separated by a single space: the number of rows, then the number of columns.
Example 1
Input
5 10 15 7 20 3
Expected
2 3
Explanation
The dump has two lines, and each line has three space-separated readings, so the grid has 2 rows and 3 columns.
Example 2
Input
(empty)Expected
0 0
Explanation
The dump is completely empty (no lines at all), so the grid is reported as having 0 rows and 0 columns.
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 →