質問編集履歴
3
コメントの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
nodes = sorted(set(nodes))[2:]
|
24
24
|
|
25
|
-
# sorted とマージさせたい
|
25
|
+
# sorted とマージさせた方が速い...?
|
26
26
|
|
27
27
|
s = 1
|
28
28
|
|
2
コメントの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,6 +34,8 @@
|
|
34
34
|
|
35
35
|
print(s)
|
36
36
|
|
37
|
+
#この時点でnodesがソートされていて欲しい
|
38
|
+
|
37
39
|
```
|
38
40
|
|
39
41
|
このような場合、sorted()を使うよりも速い方法はありますか?
|
1
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,3 +9,31 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
よろしくお願いいたします。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
コードの例を追記しますと、
|
16
|
+
|
17
|
+
```python
|
18
|
+
|
19
|
+
node = {1:0, 2:[1,0,1],3:[2,1,3],4:[3,1,5]}
|
20
|
+
|
21
|
+
nodes = [0,1,2,2,3,1,4]
|
22
|
+
|
23
|
+
nodes = sorted(set(nodes))[2:]
|
24
|
+
|
25
|
+
# sorted とマージさせたい
|
26
|
+
|
27
|
+
s = 1
|
28
|
+
|
29
|
+
for j in nodes:
|
30
|
+
|
31
|
+
if node[j][1]==1:
|
32
|
+
|
33
|
+
s *= 3
|
34
|
+
|
35
|
+
print(s)
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
このような場合、sorted()を使うよりも速い方法はありますか?
|