[Python/2015] Move solutions into .py files
This commit is contained in:
parent
8c2be5fb77
commit
94dd3ae399
52 changed files with 996 additions and 3314 deletions
13
Python/2015/09.py
Normal file
13
Python/2015/09.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 9)
|
||||
|
||||
|
||||
graph = {}
|
||||
for src, _, dst, _, dist in map(str.split, input.splitlines()):
|
||||
graph.setdefault(src, {})[dst] = int(dist)
|
||||
graph.setdefault(dst, {})[src] = int(dist)
|
||||
|
||||
|
||||
print(min(sum(graph[a][b] for a, b in zip(locs, locs[1:])) for locs in itertools.permutations(graph)))
|
||||
print(max(sum(graph[a][b] for a, b in zip(locs, locs[1:])) for locs in itertools.permutations(graph)))
|
Loading…
Add table
Add a link
Reference in a new issue