質問編集履歴
2
分かりやすくサンプルで示しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,23 +8,17 @@
|
|
8
8
|
|
9
9
|
持っていいるリスト
|
10
10
|
|
11
|
-
x_result_list=
|
11
|
+
x_result_list = [2, 2, 3, 4, 2, 5, 6, 6, 7, 8]
|
12
12
|
|
13
|
-
|
13
|
+
y_displacement_list = [50, 10, 30, 40, 20, 50, 16, 60, 70, 20]
|
14
|
-
|
15
|
-
中略
|
16
|
-
|
17
|
-
96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 97, 97, 97, 97, 97, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111]
|
18
14
|
|
19
15
|
|
20
16
|
|
21
|
-
|
17
|
+
欲しい結果
|
22
18
|
|
23
|
-
|
19
|
+
x_result_list2 = [2, 3, 4, 5, 6, 7, 8]
|
24
20
|
|
25
|
-
中略
|
26
|
-
|
27
|
-
|
21
|
+
y_displacement_list2 = [10, 30, 40, 50, 16, 70, 20]
|
28
22
|
|
29
23
|
|
30
24
|
|
@@ -36,15 +30,9 @@
|
|
36
30
|
|
37
31
|
目的の結果が得られません.x_result_list2内には同じxの値は存在しないはずなのですが結果は以下のようになります.
|
38
32
|
|
39
|
-
x_result_list2=
|
33
|
+
x_result_list2 = [2, 2, 2, 3, 4, 2, 5, 6, 6, 7, 8]
|
40
34
|
|
41
|
-
|
35
|
+
y_displacement_list2 = [10, 10, 10, 16, 16, 16, 16, 16, 16, 20, 20]
|
42
|
-
|
43
|
-
中略
|
44
|
-
|
45
|
-
97, 97, 97, 97, 97, 97, 97, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 97, 97, 97, 97, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111]
|
46
|
-
|
47
|
-
|
48
36
|
|
49
37
|
|
50
38
|
|
@@ -62,6 +50,12 @@
|
|
62
50
|
|
63
51
|
```
|
64
52
|
|
53
|
+
x_result_list = [2, 2, 3, 4, 2, 5, 6, 6, 7, 8]
|
54
|
+
|
55
|
+
y_displacement_list = [50, 10, 30, 40, 20, 50, 16, 60, 70, 20]
|
56
|
+
|
57
|
+
|
58
|
+
|
65
59
|
x_result_list2 = []
|
66
60
|
|
67
61
|
y_displacement_list2 = []
|
@@ -70,7 +64,7 @@
|
|
70
64
|
|
71
65
|
if x_result_list[i-1] != x_result_list[i]:#一度最小値求めたxの値については計算しない
|
72
66
|
|
73
|
-
for j in range(i
|
67
|
+
for j in range(i, len(x_result_list)):#jはx_result_list内を巡回するループ
|
74
68
|
|
75
69
|
if x_result_list[i] == x_result_list[j]:
|
76
70
|
|
@@ -78,7 +72,7 @@
|
|
78
72
|
|
79
73
|
min_value = y_displacement_list[i]#暫定最小値をセット
|
80
74
|
|
81
|
-
for k in range(i
|
75
|
+
for k in range(i, len(x_result_list)):
|
82
76
|
|
83
77
|
if y_displacement_list[k] < min_value:
|
84
78
|
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,6 +60,8 @@
|
|
60
60
|
|
61
61
|
```ここに言語名を入力
|
62
62
|
|
63
|
+
```
|
64
|
+
|
63
65
|
x_result_list2 = []
|
64
66
|
|
65
67
|
y_displacement_list2 = []
|
@@ -84,6 +86,10 @@
|
|
84
86
|
|
85
87
|
y_displacement_list2.append(min_value)
|
86
88
|
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
87
93
|
```
|
88
94
|
|
89
95
|
|