質問編集履歴

2

分かりやすくサンプルで示しました

2020/10/14 13:13

投稿

mk_taro5
mk_taro5

スコア5

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
- [56, 56, 56, 56, 56, 55, 55, 55, 55, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 21, 21, 21, 20, 20, 20, 20, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 4, 4, 4, 4, 4,
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
- y_displacement_list=
17
+ 欲しい結果
22
18
 
23
- [-73, -8, -23, -26, 74, -70, -8, 113, 74, -66, -64, 17, 163, -65, -63, 21, 18, 163, 162, 26, 159, 157, -54, 27, 160, 158, -44, -43, 151, -6, -44, -45, -9, 152, -40,
19
+ x_result_list2 = [2, 3, 4, 5, 6, 7, 8]
24
20
 
25
- 中略
26
-
27
- -197, -198, 0, 29, -231, -230, -188, -189, -226, -227, -29, 0, -230, -229, -33, -31, 0, -125, -124, -51, -50, -32, -31, 0, 1, -126, -125, -52, -51, -33, -32, -1, 0]
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
- [56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 32, 32, 32, 32, 32, 32, 32, 32,
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+1, len(x_result_list)):#jはi+1番目からx_result_list内を巡回するループ
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+1, len(x_result_list)):
75
+ for k in range(i, len(x_result_list)):
82
76
 
83
77
  if y_displacement_list[k] < min_value:
84
78
 

1

書式の改善

2020/10/14 13:13

投稿

mk_taro5
mk_taro5

スコア5

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