aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Lasseter <Nat Lasseter nathan@bytemark.co.uk>2017-12-25 00:44:40 +0000
committerNat Lasseter <Nat Lasseter nathan@bytemark.co.uk>2017-12-25 00:44:40 +0000
commit11114c033735fc29ddc563de23d41682a6d101e3 (patch)
tree2137edd122d3a6ac84774b2b2a586a4b16acc07f
parentbb490b1d20f58ac9aac960d140aa0f172169ebc9 (diff)
Day24 Part1
-rwxr-xr-xday24/part18
1 files changed, 5 insertions, 3 deletions
diff --git a/day24/part1 b/day24/part1
index b608bae..223d117 100755
--- a/day24/part1
+++ b/day24/part1
@@ -43,18 +43,20 @@ class BridgeFactory
end
bfs = [BridgeFactory.new(input)]
+maxs = 0
loop do
new_bfs = []
bfs.each do |bf|
if bf.complete? then
- new_bfs << bf
+ s = bf.strength
+ maxs = s if s > maxs
else
new_bfs += bf.build_iter
end
end
- break if new_bfs.map(&:complete?).all?
+ break if new_bfs.empty?
bfs = new_bfs
end
-puts bfs.map(&:strength).max
+puts maxs