2015/day-07/day-07-part-2.rb
# The value of the output wire is known if there are no more input wires
The value of the output wire is known if there are no more input wires
The value of the output wire is known if there are no more input wires
def output
    return nil if input_wires.any?
    case gate
    when "AND"
      values[0] & values[1]
    when "OR"
      values[0] | values[1]
    when "NOT"
      ~values[0]
    when "LSHIFT"
      values[0] << values[1]
    when "RSHIFT"
      values[0] >> values[1]
    else
      values[0]
    end
  end
def output return nil if input_wires . any? case gate when "AND" values [ 0 ] & values [ 1 ] when "OR" values [ 0 ] | values [ 1 ] when "NOT" ~ values [ 0 ] when "LSHIFT" values [ 0 ] << values [ 1 ] when "RSHIFT" values [ 0 ] >> values [ 1 ] else values [ 0 ] end end
The value of the output wire is known if there are no more input wires
The value of the output wire is known if there are no more input wires