Make some cosmetic changes
This commit is contained in:
parent
4455a4e6f4
commit
0e7965f06a
@ -1,6 +1,6 @@
|
||||
import time
|
||||
from itertools import permutations
|
||||
from typing import Callable, Tuple
|
||||
from typing import Tuple
|
||||
|
||||
import numpy.typing as npt
|
||||
|
||||
@ -25,8 +25,8 @@ def exhaustive_search(distances: npt.NDArray) -> Tuple[float, Tuple]:
|
||||
|
||||
size = len(distances)
|
||||
|
||||
return min( # Find the smallest travel distance from the array
|
||||
map( # Map the permutation array to contain tuples (distance, permutation)
|
||||
return min( # Find the smallest travel distance from the array
|
||||
map( # Map the permutation array to contain tuples (distance, permutation)
|
||||
lambda perm: (
|
||||
sum([distances[perm[i - 1], perm[i]] for i in range(size)]),
|
||||
perm,
|
||||
@ -53,7 +53,7 @@ if __name__ == "__main__":
|
||||
print(f"time to find solution: {time_elapsed_ms:>12.6f}ms\n")
|
||||
|
||||
|
||||
""" Running example
|
||||
"""Running example
|
||||
|
||||
oblig1 on main [?] via 🐍 v3.12.6 took 7s
|
||||
❯ python exhaustive_search.py
|
||||
|
||||
Loading…
Reference in New Issue
Block a user