11
1
You will be given a two-dimensional array and a number and you are asked to find whether the given matrix is Toeplitz or not.
Input Format:
You will be given a function which will take two-dimensional
matrix as argument.
Output Format:
Return 1
from the function if the matrix is Toeplitz, else return -1
.
Constraints:
3 < n,m < 10,000,000
where n
is the number of rows while m
will be the number of columns.
Sample Test Case:
Sample Input :
4
5
6 7 8 9 2
4 6 7 8 9
1 4 6 7 8
0 1 4 6 7
Sample Output :
1
Scoring
This is code-golf, so the shortest answer in bytes wins.
8
This is a good challenge, but we prefer laxer I/O requirements here. I'd suggest allowing both programs and functions as is the default. And to allow True/False or 1/0 as outputs, or perhaps just any two consistent distinct outputs as seems to be preferred for decision problems.
– xnor – 2017-05-18T05:59:07.58315Also, a definition of Toeplitz would be good, as would be more test cases including non-Toeplitz ones. Not sure what you mean about adding code. – xnor – 2017-05-18T06:00:51.197
5I think you must reduce the maximum value of n,m. Otherwise the main part of this challenge is to find a way to process a 1 terabyte matrix. – Stewie Griffin – 2017-05-18T07:25:19.850
1Will the matrix elements always be non-negative integers? – Martin Ender – 2017-05-18T13:52:13.150