A Shift matrix is a binary matrix with one superdiagonal or subdiagonal formed by only ones, everything else is a zero.
A superdiagonal/subdiagonal is a diagonal parallel to the main diagonal, which is not the main diagonal, i.e. all entries \$a_{ij}\$ where \$i=j+k\$ and \$k \neq 0\$.
The main diagonal is defined to be all entries \$a_{ij}\$ where \$i=j\$.
Specs
- The matrix is not guaranteed to be square and will consist of only zeros and ones
- Take a nested list or a matrix as the input
- Output a truthy/falsy result or use two distinct values to represent truthy and falsy results
- This is code-golf, the shortest answer wins!
Examples
[[1]] -> 0
[[0, 1],
[0, 0]] -> 1
[[0, 0, 0],
[1, 0, 0],
[0, 1, 0]] -> 1
[[0, 1, 0],
[1, 0, 0],
[0, 0, 0]] -> 0
[[0, 1, 0],
[0, 0, 1]] -> 1
[[0, 0],
[0, 0]] -> 0
[[0, 0, 0, 0],
[1, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 1, 0]] -> 0
[[1, 1],
[1, 1]] -> 0
[[0,1,0,0],
[1,0,1,0],
[0,1,0,1],
[0,0,1,0]] -> 0
[[0,1,0],
[1,0,0],
[0,1,0]] -> 0
[[0,1,0],
[0,0,1],
[1,0,0]] -> 0
[[1,0,0],
[0,1,0]] -> 0
[[0,0,0],
[0,0,0],
[0,0,0],
[0,0,0],
[0,0,0],
[1,0,0]] -> 1
[[1,0,1],
[0,1,0],
[0,0,1]] -> 0
[[0,1,0],
[1,0,0]] -> 0
[[1,1],[1,1]] -> 0
and[[0,1,0,0],[1,0,1,0],[0,1,0,1],[0,0,1,0]] -> 0
. \$\endgroup\$[[0,1,0],[0,0,1],[1,0,0]]->0
,[[1,0,0],[0,1,0]]->0
,[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[1,0,0]]->1
,[[1,0,1],[0,1,0],[0,0,1]]->0
\$\endgroup\$