質問編集履歴
2
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,45 +34,7 @@
|
|
34
34
|
|
35
35
|
def distance(point1, point2)
|
36
36
|
|
37
|
-
#距離
|
38
|
-
|
39
|
-
if point1[0] > point2[0]
|
40
|
-
|
41
|
-
dx = point1[0] - point2[0]
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
if point1[0] < point2[0]
|
46
|
-
|
47
|
-
dx = point2[0] - point1[0]
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
if point1[1] > point2[1]
|
52
|
-
|
53
|
-
|
37
|
+
return (point1[0] - point2[0]).abs + (point1[1] - point2[1]).abs
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
if point1[1] < point2[1]
|
58
|
-
|
59
|
-
dy = point2[1] - point1[1]
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
if point1[0] == point2[0]
|
64
|
-
|
65
|
-
dx = 0
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
if point1[1] == point2[1]
|
70
|
-
|
71
|
-
dy = 0
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
return dx + dy
|
76
38
|
|
77
39
|
end
|
78
40
|
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,15 @@
|
|
14
14
|
|
15
15
|
**関数「distance」の定義の仕方のせいで壁(通らない座標)を通る場合の距離になってしまいます...**
|
16
16
|
|
17
|
-
|
17
|
+
```result
|
18
|
+
|
19
|
+
:kaku_route
|
20
|
+
|
21
|
+
[[1, 13], [1, 12], [1, 11], [1, 10], [2, 10], [2, 11], [3, 11], [4, 11], [4, 10]]
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
**最短経路が求まりません...
|
18
26
|
|
19
27
|
### 該当のソースコード
|
20
28
|
|