How to make a matrix with a size of 2 cells?
I need a matrix like a chessboard but with two cells in one place
the matrix should have size n X m, cells size 2 X 2 I wrote this code: [In]:
def mat(n, m):
sq = np.zeros((n, m))
sq[::2, 1::2] = 1
sq[1::2, ::2] = 1
a = str(sq).replace('.', '')
print(a)
mat(10, 10)
[Out]:
[0 1 0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0 1 0]
[0 1 0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0 1 0]
[0 1 0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0 1 0]
[0 1 0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0 1 0]
but I need it like this:
[0 0 1 1 0 0 1 1 0 0]
[0 0 1 1 0 0 1 1 0 0]
[1 1 0 0 1 1 0 0 1 1]
[1 1 0 0 1 1 0 0 1 1]
[0 0 1 1 0 0 1 1 0 0]
[0 0 1 1 0 0 1 1 0 0]
[1 1 0 0 1 1 0 0 1 1]
[1 1 0 0 1 1 0 0 1 1]
[0 0 1 1 0 0 1 1 0 0]
[0 0 1 1 0 0 1 1 0 0]