[2024][ruby][10.x] refactored to bring part one back

main
Alpha Chen 2 days ago
parent afd49ca1c6
commit 7b117f5370
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -26,13 +26,18 @@ def trails(map, head)
end
finished
.select { _1.length > 2 && map.fetch(_1.last) == 9 }
.select { map.fetch(_1.last) == 9 }
.uniq
end
# part one
pp trailheads.sum { trails(map, _1).map(&:last).uniq.length }
# part two
pp trailheads.sum { trails(map, _1).length }
__END__
89010123
78121874
87430965
96549874

Loading…
Cancel
Save