rougier/numpy-100

An alternative solution for Q.19

HenryJi529 opened this issue · 2 comments

  1. Create a 8x8 matrix and fill it with a checkerboard pattern (★☆☆)

Z = np.zeros((8,8),dtype=int)
Z[1::2,::2] = 1
Z[::2,1::2] = 1
print(Z)

An alternative solution will be:

arr = np.ones(64,dtype=int)
arr[::2]=0
arr = arr.reshape((8,8))
print(arr)

Clever. Can you make a PR adding your solution following the existing one? (Make sure to edit the template and not the .md or .ipynd files)

Sure.
Again, thanks for your numpy-100 practice, it really helps me a lot.