回答編集履歴
4
誤字修正
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
list
|
15
|
+
list0 = [0, 1, 2, 3, 0, 1, 2, 3]
|
16
16
|
|
17
|
-
list
|
17
|
+
list1 = [3, 1, 4, 5, 1, 2, 4, 3]
|
18
18
|
|
19
19
|
|
20
20
|
|
@@ -30,13 +30,17 @@
|
|
30
30
|
|
31
31
|
# zip 関数と辞書型を使いました!
|
32
32
|
|
33
|
-
reduce(accumulate, zip(list
|
33
|
+
count = lambda list0, list1: reduce(accumulate, zip(list0, list1), dict())
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
count(list0, list1)
|
34
38
|
|
35
39
|
```
|
36
40
|
|
37
41
|
```
|
38
42
|
|
39
|
-
>>>
|
43
|
+
>>> count(list0, list1)
|
40
44
|
|
41
45
|
{0: 4, 1: 3, 2: 8, 3: 8}
|
42
46
|
|
3
誤字
test
CHANGED
@@ -22,9 +22,7 @@
|
|
22
22
|
|
23
23
|
key, value = layer
|
24
24
|
|
25
|
-
prev = pile.get(key) if pile.get(key) is not None else 0
|
26
|
-
|
27
|
-
pile[key] = p
|
25
|
+
pile[key] = pile.get(key, 0) + value
|
28
26
|
|
29
27
|
return pile
|
30
28
|
|
2
誤字
test
CHANGED
@@ -18,9 +18,9 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
def accumulate(pile,
|
21
|
+
def accumulate(pile, layer):
|
22
22
|
|
23
|
-
key, value =
|
23
|
+
key, value = layer
|
24
24
|
|
25
25
|
prev = pile.get(key) if pile.get(key) is not None else 0
|
26
26
|
|
1
誤字
test
CHANGED
@@ -22,9 +22,9 @@
|
|
22
22
|
|
23
23
|
key, value = data
|
24
24
|
|
25
|
-
prev = pile.get(key)
|
25
|
+
prev = pile.get(key) if pile.get(key) is not None else 0
|
26
26
|
|
27
|
-
pile[key] = prev + value
|
27
|
+
pile[key] = prev + value
|
28
28
|
|
29
29
|
return pile
|
30
30
|
|