[2022][ruby][5.x] refactor
change ytqxnzrvtmwyxvymqnmorkuuyxolvwtx
commit 84b24f2587923e3406fdbe9bc3ec157ace496772
author Alpha Chen <alpha@kejadlen.dev>
date
parent uxuzyutv
diff --git a/2022/ruby/day_05.rb b/2022/ruby/day_05.rb
index 0f7c927..2600d1f 100644
--- a/2022/ruby/day_05.rb
+++ b/2022/ruby/day_05.rb
@@ -4,8 +4,8 @@ setup = setup
   .lines(chomp: true)
   .map(&:chars)
   .transpose
-  .select { _1.last =~ /\d/ }
-  .map { _1[0..-2].join.strip.chars }
+  .map {|col| col.select { _1 =~ /[A-Z]/ }}
+  .reject(&:empty?)
 
 moves = moves.scan(/move (\d+) from (\d+) to (\d+)/).map { _1.map(&:to_i) }
 moves.each do |n,from,to|