質問編集履歴

3

誤字

2021/04/24 13:58

投稿

hirochem
hirochem

スコア4

test CHANGED
File without changes
test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
  ### 該当のソースコード
44
44
 
45
- パターン1
45
+ **パターン1**
46
46
 
47
47
  ```html
48
48
 
@@ -104,7 +104,7 @@
104
104
 
105
105
 
106
106
 
107
- パターン2
107
+ **パターン2**
108
108
 
109
109
  ```html
110
110
 
@@ -160,7 +160,7 @@
160
160
 
161
161
 
162
162
 
163
- パターン3
163
+ **パターン3**
164
164
 
165
165
  ```html
166
166
 

2

書式の改善

2021/04/24 13:58

投稿

hirochem
hirochem

スコア4

test CHANGED
File without changes
test CHANGED
@@ -44,7 +44,9 @@
44
44
 
45
45
  パターン1
46
46
 
47
+ ```html
48
+
47
- 'import numpy as np
49
+ import numpy as np
48
50
 
49
51
  stock = [3,2]
50
52
 
@@ -84,9 +86,67 @@
84
86
 
85
87
  for a in ans:
86
88
 
89
+ print(a)
90
+
91
+ ```
92
+
93
+
94
+
95
+ 出力
96
+
97
+ 2,0
98
+
99
+ Not enough
100
+
101
+ 3,1
102
+
103
+ Not enough
104
+
105
+
106
+
107
+ パターン2
108
+
109
+ ```html
110
+
111
+ import numpy as np
112
+
113
+ stock = [3,2]
114
+
115
+ act = ["sub", "sub", "add", "sub", "sub"]
116
+
117
+ change = [[1,2], [3,0], [3, 2], [2,1], [2,2]]
118
+
119
+ ans = []
120
+
121
+ for a, b in zip(act, change):
122
+
123
+ tes = (np.array(stock)-np.array(b)).tolist()
124
+
125
+ if a == "sub":
126
+
127
+ if all((x>=0 for x in tes)):
128
+
129
+ for e, (p, b2) in enumerate(zip(stock, b)):
130
+
131
+ stock[e] -= b2 #stockの個数を変更
132
+
133
+ ans.append(",".join([str(a) for a in stock]))
134
+
135
+ else:
136
+
137
+ ans.append("Not enough")
138
+
139
+ elif a =="add":
140
+
141
+ for e, (p,b2) in enumerate(zip(stock, b)):
142
+
143
+ stock[e] += b2
144
+
145
+ for a in ans:
146
+
87
147
  print(a)'
88
148
 
89
-
149
+ ```
90
150
 
91
151
  出力
92
152
 
@@ -100,9 +160,11 @@
100
160
 
101
161
 
102
162
 
103
- パターン
163
+ パターン3
164
+
104
-
165
+ ```html
166
+
105
- 'import numpy as np
167
+ import numpy as np
106
168
 
107
169
  stock = [3,2]
108
170
 
@@ -114,11 +176,11 @@
114
176
 
115
177
  for a, b in zip(act, change):
116
178
 
117
- tes = (np.array(stock)-np.array(b)).tolist()
179
+ tes = np.array(stock)-np.array(b)
118
180
 
119
181
  if a == "sub":
120
182
 
121
- if all((x>=0 for x in tes)):
183
+ if np.all(x>=0 for x in tes): #これが上手く動作していない?
122
184
 
123
185
  for e, (p, b2) in enumerate(zip(stock, b)):
124
186
 
@@ -140,66 +202,12 @@
140
202
 
141
203
  print(a)'
142
204
 
143
-
205
+ ```
144
206
 
145
207
  出力
146
208
 
147
209
  2,0
148
210
 
149
- Not enough
150
-
151
- 3,1
152
-
153
- Not enough
154
-
155
-
156
-
157
- パターン3
158
-
159
- 'import numpy as np
160
-
161
- stock = [3,2]
162
-
163
- act = ["sub", "sub", "add", "sub", "sub"]
164
-
165
- change = [[1,2], [3,0], [3, 2], [2,1], [2,2]]
166
-
167
- ans = []
168
-
169
- for a, b in zip(act, change):
170
-
171
- tes = np.array(stock)-np.array(b)
172
-
173
- if a == "sub":
174
-
175
- if np.all(x>=0 for x in tes): #これが上手く動作していない?
176
-
177
- for e, (p, b2) in enumerate(zip(stock, b)):
178
-
179
- stock[e] -= b2 #stockの個数を変更
180
-
181
- ans.append(",".join([str(a) for a in stock]))
182
-
183
- else:
184
-
185
- ans.append("Not enough")
186
-
187
- elif a =="add":
188
-
189
- for e, (p,b2) in enumerate(zip(stock, b)):
190
-
191
- stock[e] += b2
192
-
193
- for a in ans:
194
-
195
- print(a)'
196
-
197
-
198
-
199
- 出力
200
-
201
- 2,0
202
-
203
211
  -1,0
204
212
 
205
213
  0,1

1

書式の改善

2021/04/24 13:56

投稿

hirochem
hirochem

スコア4

test CHANGED
File without changes
test CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
  パターン1
46
46
 
47
- import numpy as np
47
+ 'import numpy as np
48
48
 
49
49
  stock = [3,2]
50
50
 
@@ -84,7 +84,7 @@
84
84
 
85
85
  for a in ans:
86
86
 
87
- print(a)
87
+ print(a)'
88
88
 
89
89
 
90
90
 
@@ -102,7 +102,7 @@
102
102
 
103
103
  パターン2
104
104
 
105
- import numpy as np
105
+ 'import numpy as np
106
106
 
107
107
  stock = [3,2]
108
108
 
@@ -138,7 +138,7 @@
138
138
 
139
139
  for a in ans:
140
140
 
141
- print(a)
141
+ print(a)'
142
142
 
143
143
 
144
144
 
@@ -156,7 +156,7 @@
156
156
 
157
157
  パターン3
158
158
 
159
- import numpy as np
159
+ 'import numpy as np
160
160
 
161
161
  stock = [3,2]
162
162
 
@@ -192,7 +192,7 @@
192
192
 
193
193
  for a in ans:
194
194
 
195
- print(a)
195
+ print(a)'
196
196
 
197
197
 
198
198