From 09db2ae1a04f3ccbcd55f85fb2e3bb04bda1f093 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Tue, 10 Dec 2024 21:06:52 -0800 Subject: [PATCH] [2024][ruby][11.1] --- 2024/ruby/day_11.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 2024/ruby/day_11.rb diff --git a/2024/ruby/day_11.rb b/2024/ruby/day_11.rb new file mode 100644 index 0000000..eba46bc --- /dev/null +++ b/2024/ruby/day_11.rb @@ -0,0 +1,18 @@ +stones = DATA.read.scan(/\d+/).map(&:to_i) + +25.times { + stones = stones.flat_map {|n| + if n.zero? + [1] + elsif (s = n.to_s.size) && s.even? + [n.to_s[0...s/2], n.to_s[s/2..]].map(&:to_i) + else + [n * 2024] + end + } +} + +pp stones.length + +__END__ +1750884 193 866395 7 1158 31 35216 0