回答編集履歴
4
修正
answer
CHANGED
@@ -11,7 +11,6 @@
|
|
11
11
|
for h in range(a):
|
12
12
|
score_total += s
|
13
13
|
human_total += 1
|
14
|
-
print(score_total, human_total)
|
15
14
|
if human_total >= num_of_human:
|
16
15
|
break
|
17
16
|
if human_total >= num_of_human:
|
3
修正・追記
answer
CHANGED
@@ -1,7 +1,21 @@
|
|
1
|
-
すみません、
|
1
|
+
すみません、修正しました。慌てて作ったのでちょっと良くないコードですね...
|
2
|
-
|
2
|
+
```Python
|
3
|
+
score = [500, 400, 300, 200, 100, 50, 0]
|
4
|
+
amount = [3, 8, 3, 5, 10, 3, 1]
|
3
5
|
|
6
|
+
num_of_human = 10
|
7
|
+
|
4
|
-
|
8
|
+
score_total = 0
|
5
|
-
|
9
|
+
human_total = 0
|
10
|
+
for s, a in zip(score, amount):
|
11
|
+
for h in range(a):
|
12
|
+
score_total += s
|
13
|
+
human_total += 1
|
14
|
+
print(score_total, human_total)
|
15
|
+
if human_total >= num_of_human:
|
16
|
+
break
|
17
|
+
if human_total >= num_of_human:
|
18
|
+
break
|
19
|
+
|
6
|
-
wt_avg =
|
20
|
+
wt_avg = score_total / num_of_human
|
7
21
|
```
|
2
修正
answer
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
すみません、ちょっと問題設定を勘違いしていました。
|
2
|
+
下記の回答はスルーしてください。
|
3
|
+
|
1
4
|
スライスを使えばよいです。
|
2
5
|
```Python
|
3
6
|
wt_avg = sum([s*a for s,a in zip(score[:n],amount[:n])]) / sum(amount[:n])
|
1
修正
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
スライスを使えばよいです。
|
2
2
|
```Python
|
3
|
-
wt_avg = sum([s*a for s,a in zip(score[:n],amount[:n])]) / n
|
3
|
+
wt_avg = sum([s*a for s,a in zip(score[:n],amount[:n])]) / sum(amount[:n])
|
4
4
|
```
|