Solved 2017/24 P2
This commit is contained in:
parent
2fe83ed32b
commit
fb04866c9c
@ -61,8 +61,6 @@ components you have available?
|
|||||||
|
|
||||||
Your puzzle answer was `2006`.
|
Your puzzle answer was `2006`.
|
||||||
|
|
||||||
The first half of this puzzle is complete! It provides one gold star: \*
|
|
||||||
|
|
||||||
## \-\-- Part Two \-\-- {#part2}
|
## \-\-- Part Two \-\-- {#part2}
|
||||||
|
|
||||||
The bridge you\'ve built isn\'t long enough; you can\'t [jump the rest
|
The bridge you\'ve built isn\'t long enough; you can\'t [jump the rest
|
||||||
@ -79,8 +77,14 @@ strength is `0+2 + 2+2 + 2+3 + 3+5 = 19`.
|
|||||||
*What is the strength of the longest bridge you can make?* If you can
|
*What is the strength of the longest bridge you can make?* If you can
|
||||||
make multiple bridges of the longest length, pick the *strongest* one.
|
make multiple bridges of the longest length, pick the *strongest* one.
|
||||||
|
|
||||||
Answer:
|
Your puzzle answer was `1994`.
|
||||||
|
|
||||||
Although it hasn\'t changed, you can still [get your puzzle
|
Both parts of this puzzle are complete! They provide two gold stars:
|
||||||
|
\*\*
|
||||||
|
|
||||||
|
At this point, you should [return to your Advent calendar](/2017) and
|
||||||
|
try another puzzle.
|
||||||
|
|
||||||
|
If you still want to see it, you can [get your puzzle
|
||||||
input](24/input).
|
input](24/input).
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ def make_bridge(components, last):
|
|||||||
|
|
||||||
if part == 1:
|
if part == 1:
|
||||||
components = parse_input(input_f)
|
components = parse_input(input_f)
|
||||||
#print(components)
|
|
||||||
|
|
||||||
bridge = make_bridge(components,0)
|
bridge = make_bridge(components,0)
|
||||||
print(bridge)
|
print(bridge)
|
||||||
@ -59,9 +58,8 @@ def make_bridge_longest(components, last):
|
|||||||
tmp = component[1]
|
tmp = component[1]
|
||||||
else:
|
else:
|
||||||
tmp = component[0]
|
tmp = component[0]
|
||||||
x = component + make_bridge(components[:cdx]+components[cdx+1:],tmp)
|
x = component + make_bridge_longest(components[:cdx]+components[cdx+1:],tmp)
|
||||||
if len(x) > len(longest_bridge) and sum(x) > score:
|
if len(x) >= len(longest_bridge):
|
||||||
score = sum(x)
|
|
||||||
longest_bridge = x
|
longest_bridge = x
|
||||||
|
|
||||||
return longest_bridge
|
return longest_bridge
|
||||||
@ -69,11 +67,5 @@ def make_bridge_longest(components, last):
|
|||||||
|
|
||||||
if part == 2:
|
if part == 2:
|
||||||
components = parse_input(input_f)
|
components = parse_input(input_f)
|
||||||
#print(components)
|
|
||||||
|
|
||||||
bridge = make_bridge_longest(components,0)
|
bridge = make_bridge_longest(components,0)
|
||||||
|
print(sum(bridge))
|
||||||
print(bridge)
|
|
||||||
#print(sum(bridge))
|
|
||||||
|
|
||||||
#print(sum(bridge))
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user