From d45a1cd4556c24c036dad488d182ce91237bf6fa Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Fri, 6 Dec 2024 07:27:32 -0800 Subject: [PATCH] [2024][ruby][6.x] optimize obstacles --- 2024/ruby/day_06.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/2024/ruby/day_06.rb b/2024/ruby/day_06.rb index 3e6f3ea..8ef0cf0 100644 --- a/2024/ruby/day_06.rb +++ b/2024/ruby/day_06.rb @@ -44,10 +44,11 @@ rescue Loop true end -pp patrol(input).map(&:first).to_set.length +path = patrol(input).map(&:first).to_set +pp path.length pp input - .select { _2 == ?. } + .select { path.include?(_1) && _2 != ?^ } .select {|xy, _| # pp xy input[xy] = ?#