From 7b117f5370635a505d18a3ad7405ace9b411817c Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Mon, 9 Dec 2024 21:40:17 -0800 Subject: [PATCH] [2024][ruby][10.x] refactored to bring part one back --- 2024/ruby/day_10.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/2024/ruby/day_10.rb b/2024/ruby/day_10.rb index 41fa51a..6b2625a 100644 --- a/2024/ruby/day_10.rb +++ b/2024/ruby/day_10.rb @@ -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