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