diff --git a/2023/ruby/day_08.rb b/2023/ruby/day_08.rb index 92e73f9..4eb1990 100644 --- a/2023/ruby/day_08.rb +++ b/2023/ruby/day_08.rb @@ -23,8 +23,4 @@ p steps.("AAA", /ZZZ/) # part two nodes = network.keys.select { _1.end_with?(?A) } node_steps = nodes.map { steps.(_1, /Z$/) } -p node_steps - .map { Prime.prime_division(_1).to_h } - .inject {|acc, fac| acc.merge(fac) {|_,old,new| [old, new].max}} - .map { _1**_2 } - .inject(:*) +p node_steps.inject(1, :lcm)