From 55d37d781924626526d49f397efce48b64e5804a Mon Sep 17 00:00:00 2001 From: Haksell Date: Sat, 2 May 2020 07:23:15 +0200 Subject: [PATCH 1/3] Fix answer 9 --- source/exercises100.ktx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/exercises100.ktx b/source/exercises100.ktx index 1840c42..837d273 100644 --- a/source/exercises100.ktx +++ b/source/exercises100.ktx @@ -85,8 +85,8 @@ Create a 3x3 matrix with values ranging from 0 to 8 (★☆☆) hint: reshape < a9 -nz = np.nonzero([1,2,0,0,4,0]) -print(nz) +Z = np.arange(9).reshape(3, 3) +print(Z) < q10 Find indices of non-zero elements from [1,2,0,0,4,0] (★☆☆) From 04f01dc162977acc8c113ce2a8ae382d23d531ea Mon Sep 17 00:00:00 2001 From: Haksell Date: Sat, 2 May 2020 07:30:46 +0200 Subject: [PATCH 2/3] Alternative answer to question 19 --- source/exercises100.ktx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/exercises100.ktx b/source/exercises100.ktx index 837d273..0adcf6a 100644 --- a/source/exercises100.ktx +++ b/source/exercises100.ktx @@ -201,9 +201,7 @@ Create a 8x8 matrix and fill it with a checkerboard pattern (★☆☆) hint: array[::2] < a19 -Z = np.zeros((8,8),dtype=int) -Z[1::2,::2] = 1 -Z[::2,1::2] = 1 +Z = np.array([[(i + j) % 2 for j in range(8)] for i in range(8)]) print(Z) < q20 From 76d42c7795fcf77c41be5735bd5ae2d8603e59fc Mon Sep 17 00:00:00 2001 From: Haksell Date: Sat, 2 May 2020 07:36:55 +0200 Subject: [PATCH 3/3] revert to previous commit like a noob --- source/exercises100.ktx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/exercises100.ktx b/source/exercises100.ktx index 0adcf6a..837d273 100644 --- a/source/exercises100.ktx +++ b/source/exercises100.ktx @@ -201,7 +201,9 @@ Create a 8x8 matrix and fill it with a checkerboard pattern (★☆☆) hint: array[::2] < a19 -Z = np.array([[(i + j) % 2 for j in range(8)] for i in range(8)]) +Z = np.zeros((8,8),dtype=int) +Z[1::2,::2] = 1 +Z[::2,1::2] = 1 print(Z) < q20