grid of zeros and ones. Call a *corner* any set of three different cells holding ones where one cell (the vertex) shares a row with the second cell and a column with the third. The cells do not have to be adjacent.
Return the number of corners in the table. Two triples made of the same three cells count as one corner.grid=[[1, 1, 0], [0, 1, 0], [1, 0, 1]] → 3
Three triples work: corner (0, 0) with (0, 1) and (2, 0); corner (0, 1) with (0, 0) and (1, 1); corner (2, 0) with (2, 2) and (0, 0).
grid=[[1, 0], [0, 1]] → 0
There are only two ones, and they share neither a row nor a column.
grid=[[1, 1], [1, 1]] → 4
Each of the four ones can be the corner, and the other two are then fixed, giving 4 triples.
grid[i][j] is 0 or 1grid=[[1, 1, 0], [0, 1, 0], [1, 0, 1]]
3
Run checks the first 3 tests in your browser. Submit checks all 70 tests on the server, hidden ones included.