Skip to content

Instantly share code, notes, and snippets.

@vladris
Last active January 6, 2018 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladris/73e4f89d2f2011b4c86fea70a290725c to your computer and use it in GitHub Desktop.
Save vladris/73e4f89d2f2011b4c86fea70a290725c to your computer and use it in GitHub Desktop.
Solution for Adevent of Code 2017/Day 24
components = [tuple(map(int, line.strip().split('/'))) for line in open("input.txt").readlines()]
def best_bridge(end, components):
result = 0
for i, c in enumerate(components):
if end == c[0]:
new_end = c[1]
elif end == c[1]:
new_end = c[0]
else:
continue
result = max(result, end + new_end + best_bridge(new_end, components[:i] + components[i+1:]))
return result
print(best_bridge(0, components))
@vladris
Copy link
Author

vladris commented Jan 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment