pattern of size n × n: each cell holds a thread number, and 0 means the cell is empty.
The design is a **cross** when:
- neither diagonal (top-left to bottom-right, and top-right to bottom-left) has an empty cell;
- every cell off the diagonals is empty.
Return True if pattern is a cross, and False otherwise.pattern=[[4, 0, 7], [0, 9, 0], [1, 0, 3]] → True
Both diagonals are filled (4, 9, 3 and 7, 9, 1) and every other cell is zero, so it is a cross.
pattern=[[2, 0, 0, 5], [0, 1, 6, 0], [0, 8, 0, 0], [3, 0, 0, 4]] → False
The cell on the main diagonal in the third row is 0, so a stitch is missing.
pattern=[[1, 0, 1], [0, 1, 0], [1, 2, 1]] → False
The diagonals are filled, but there is a stray stitch (2) in the middle of the bottom row.
pattern is a square n × n tablepattern[i][j] ≤ 10⁵pattern=[[4, 0, 7], [0, 9, 0], [1, 0, 3]]
True
Run checks the first 3 tests in your browser. Submit checks all 73 tests on the server, hidden ones included.