2020-04-21 12:42:19 -04:00
|
|
|
---
|
|
|
|
id: 5e9a0a8e09c5df3cc3600ed6
|
|
|
|
title: Initialize Array Problem
|
|
|
|
challengeType: 11
|
|
|
|
videoId: 0jGfH8BPfOk
|
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
2020-08-04 20:56:41 +01:00
|
|
|
|
2020-04-21 12:42:19 -04:00
|
|
|
<section id='description'>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Tests
|
2020-08-04 20:56:41 +01:00
|
|
|
|
2020-04-21 12:42:19 -04:00
|
|
|
<section id='tests'>
|
|
|
|
|
2020-08-04 20:56:41 +01:00
|
|
|
````yml
|
2020-04-21 12:42:19 -04:00
|
|
|
question:
|
2020-05-28 22:40:36 +09:00
|
|
|
text: |
|
2020-08-04 20:56:41 +01:00
|
|
|
What is another way to produce the following array?
|
2020-05-28 22:40:36 +09:00
|
|
|
|
2020-08-04 20:56:41 +01:00
|
|
|
```py
|
2020-10-01 14:08:57 -07:00
|
|
|
[[0. 0. 0. 0. 0. 0. 0.]
|
|
|
|
[0. 1. 1. 1. 1. 1. 0.]
|
|
|
|
[0. 1. 1. 1. 1. 1. 0.]
|
|
|
|
[0. 1. 1. 5. 1. 1. 0.]
|
|
|
|
[0. 1. 1. 1. 1. 1. 0.]
|
|
|
|
[0. 1. 1. 1. 1. 1. 0.]
|
|
|
|
[0. 0. 0. 0. 0. 0. 0.]]
|
2020-05-28 22:40:36 +09:00
|
|
|
```
|
|
|
|
|
2020-04-21 12:42:19 -04:00
|
|
|
answers:
|
2020-05-28 22:40:36 +09:00
|
|
|
- |
|
|
|
|
```py
|
2020-10-01 14:08:57 -07:00
|
|
|
output = np.ones((7, 7))
|
2020-05-28 22:40:36 +09:00
|
|
|
|
2020-10-01 14:08:57 -07:00
|
|
|
z = np.zeros((5, 5))
|
|
|
|
z[2, 2] = 5
|
2020-05-28 22:40:36 +09:00
|
|
|
|
2020-10-01 14:08:57 -07:00
|
|
|
output[1:1, -1:-1] = z
|
2020-05-28 22:40:36 +09:00
|
|
|
```
|
|
|
|
- |
|
|
|
|
```py
|
2020-10-01 14:08:57 -07:00
|
|
|
output = np.zeros((7,7))
|
2020-05-28 22:40:36 +09:00
|
|
|
|
2020-10-01 14:08:57 -07:00
|
|
|
z = np.ones((5, 5))
|
|
|
|
z[2, 2] = 5
|
2020-05-28 22:40:36 +09:00
|
|
|
|
2020-10-01 14:08:57 -07:00
|
|
|
output[1:-1, 1:-1] = z
|
2020-05-28 22:40:36 +09:00
|
|
|
```
|
|
|
|
- |
|
|
|
|
```py
|
2020-10-01 14:08:57 -07:00
|
|
|
output = np.ones((7, 7))
|
2020-05-28 22:40:36 +09:00
|
|
|
|
2020-10-01 14:08:57 -07:00
|
|
|
z = np.zeros((5, 5))
|
|
|
|
z[3, 3] = 5
|
2020-05-28 22:40:36 +09:00
|
|
|
|
2020-10-01 14:08:57 -07:00
|
|
|
output[1:-1, 1:-1] = z
|
2020-05-28 22:40:36 +09:00
|
|
|
```
|
2020-10-01 14:08:57 -07:00
|
|
|
solution: 2
|
2020-08-04 20:56:41 +01:00
|
|
|
````
|
2020-04-21 12:42:19 -04:00
|
|
|
|
|
|
|
</section>
|