diff --git a/24/main.rb b/24/main.rb index f0e5f60..dfb703a 100755 --- a/24/main.rb +++ b/24/main.rb @@ -36,6 +36,11 @@ until gates.empty? gates.delete(gate) end +p wires.select { _1.match?(/^x/) }.sort_by(&:first).map { _1.last.to_s }.reverse.join.to_i(2) +p wires.select { _1.match?(/^y/) }.sort_by(&:first).map { _1.last.to_s }.reverse.join.to_i(2) +x = wires.select { _1.match?(/^x/) }.sort_by(&:first).map { _1.last.to_s }.reverse.join.to_i(2) +y = wires.select { _1.match?(/^y/) }.sort_by(&:first).map { _1.last.to_s }.reverse.join.to_i(2) +p (x + y) p wires.select { _1.match?(/^z/) }.sort_by(&:first).map { _1.last.to_s }.reverse.join.to_i(2) __END__