From fccab23c7e10d91a382c370a2c2d35d8dabf87cc Mon Sep 17 00:00:00 2001 From: Henry Ji Date: Mon, 10 Oct 2022 20:58:25 +0800 Subject: [PATCH] Add alternative solution for Q.19 --- source/exercises100.ktx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/exercises100.ktx b/source/exercises100.ktx index dde5dfa..5e8f8d5 100644 --- a/source/exercises100.ktx +++ b/source/exercises100.ktx @@ -211,6 +211,12 @@ Z[1::2,::2] = 1 Z[::2,1::2] = 1 print(Z) +# Alternative solution: Using reshaping +arr = np.ones(64,dtype=int) +arr[::2]=0 +arr = arr.reshape((8,8)) +print(arr) + < q20 Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)