回答編集履歴
4
Update
test
CHANGED
@@ -1,43 +1,3 @@
|
|
1
|
-
一旦リストにしてから `numpy.ndarray` に変換してみてはどうでしょうか。変換の際には `dtype` を `object` にしておきます。
|
2
|
-
|
3
|
-
```python
|
4
|
-
|
5
|
-
import numpy as np
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
maze = np.array(
|
10
|
-
|
11
|
-
[
|
12
|
-
|
13
|
-
[['-', '-', '-'], ['-', '-', '-']],
|
14
|
-
|
15
|
-
[['-', '-', '-'], ['-', '-', '-']]
|
16
|
-
|
17
|
-
], dtype=object)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
maze = np.array([[''.join(y) for y in x] for x in maze], dtype=object)
|
22
|
-
|
23
|
-
print(maze)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
#
|
28
|
-
|
29
|
-
[['---' '---']
|
30
|
-
|
31
|
-
['---' '---']]
|
32
|
-
|
33
|
-
```
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
**追記**
|
38
|
-
|
39
|
-
|
40
|
-
|
41
1
|
以下は `numpy.ndarray.sum()` を使う方法です。
|
42
2
|
|
43
3
|
|
@@ -62,7 +22,7 @@
|
|
62
22
|
|
63
23
|
# join
|
64
24
|
|
65
|
-
joined = maze.sum(axis=
|
25
|
+
joined = maze.sum(axis=-1)
|
66
26
|
|
67
27
|
|
68
28
|
|
3
Update
test
CHANGED
@@ -31,3 +31,65 @@
|
|
31
31
|
['---' '---']]
|
32
32
|
|
33
33
|
```
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
**追記**
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
以下は `numpy.ndarray.sum()` を使う方法です。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```python
|
46
|
+
|
47
|
+
import numpy as np
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
maze = np.array(
|
52
|
+
|
53
|
+
[
|
54
|
+
|
55
|
+
[['-', '-', '-'], ['-', '-', '-']],
|
56
|
+
|
57
|
+
[['-', '-', '-'], ['-', '-', '-']]
|
58
|
+
|
59
|
+
], dtype=object)
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
# join
|
64
|
+
|
65
|
+
joined = maze.sum(axis=2)
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
print(f'maze:\n{maze}')
|
70
|
+
|
71
|
+
print(f'joined:\n{joined}')
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
maze:
|
76
|
+
|
77
|
+
[[['-' '-' '-']
|
78
|
+
|
79
|
+
['-' '-' '-']]
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
[['-' '-' '-']
|
84
|
+
|
85
|
+
['-' '-' '-']]]
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
joined:
|
90
|
+
|
91
|
+
[['---' '---']
|
92
|
+
|
93
|
+
['---' '---']]
|
94
|
+
|
95
|
+
```
|
2
Update
test
CHANGED
@@ -2,7 +2,23 @@
|
|
2
2
|
|
3
3
|
```python
|
4
4
|
|
5
|
+
import numpy as np
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
maze = np.array(
|
10
|
+
|
11
|
+
[
|
12
|
+
|
13
|
+
[['-', '-', '-'], ['-', '-', '-']],
|
14
|
+
|
15
|
+
[['-', '-', '-'], ['-', '-', '-']]
|
16
|
+
|
17
|
+
], dtype=object)
|
18
|
+
|
19
|
+
|
20
|
+
|
5
|
-
maze = np.array([''.join(
|
21
|
+
maze = np.array([[''.join(y) for y in x] for x in maze], dtype=object)
|
6
22
|
|
7
23
|
print(maze)
|
8
24
|
|
@@ -10,6 +26,8 @@
|
|
10
26
|
|
11
27
|
#
|
12
28
|
|
13
|
-
['---' '---']
|
29
|
+
[['---' '---']
|
30
|
+
|
31
|
+
['---' '---']]
|
14
32
|
|
15
33
|
```
|
1
Update
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
```python
|
4
4
|
|
5
|
-
maze = np.array([
|
5
|
+
maze = np.array([''.join(x) for x in maze], dtype=object)
|
6
6
|
|
7
7
|
print(maze)
|
8
8
|
|
@@ -10,8 +10,6 @@
|
|
10
10
|
|
11
11
|
#
|
12
12
|
|
13
|
-
[
|
13
|
+
['---' '---']
|
14
|
-
|
15
|
-
['---']]
|
16
14
|
|
17
15
|
```
|