From 9005e65ebc23b728cdeadfcea3b8ce3f3a8ed5ac Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 24 Dec 2024 11:18:57 -0500 Subject: [PATCH] Print bad data --- 24/main.rb | 5 +++++ 1 file changed, 5 insertions(+) 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__