Calculate the distance between two coordinate points >>> distance([0, 0], [3, 4] ) 5.0 >>> distance([0, 0], [-3, 4] ) 5.0 >>> distance([0, 0], [-3, -4] ) 5.0
(city1: list[int], city2: list[int])
| 100 | |
| 101 | |
| 102 | def distance(city1: list[int], city2: list[int]) -> float: |
| 103 | """ |
| 104 | Calculate the distance between two coordinate points |
| 105 | >>> distance([0, 0], [3, 4] ) |
| 106 | 5.0 |
| 107 | >>> distance([0, 0], [-3, 4] ) |
| 108 | 5.0 |
| 109 | >>> distance([0, 0], [-3, -4] ) |
| 110 | 5.0 |
| 111 | """ |
| 112 | return (((city1[0] - city2[0]) ** 2) + ((city1[1] - city2[1]) ** 2)) ** 0.5 |
| 113 | |
| 114 | |
| 115 | def pheromone_update( |
no outgoing calls
no test coverage detected