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