sets/lib/sets/mighty_set.rb
def simplify_array(array)
      simpler_array = Array.new
      is_positive_number = nil

      cumulative_sum = 0
      array.each do |number|
        if is_positive_number.nil? || is_positive_number == (number >= 0)
          cumulative_sum += number
        else
          simpler_array << cumulative_sum

          cumulative_sum = number
        end

        is_positive_number = number >= 0
      end

      simpler_array << cumulative_sum
    end
# Sum all contiguous positive numbers
# Sum all contiguous negative numbers
# Returns an array with alternating postive and negative numbers
Sum all contiguous positive numbers
Sum all contiguous negative numbers
Returns an array with alternating postive and negative numbers
Sum all contiguous positive numbers Sum all contiguous negative numbers Returns an array with alternating postive and negative numbers
def simplify_array(array)
      simpler_array = Array.new
      is_positive_number = nil
      cumulative_sum = 0
      array.each do |number|
        if is_positive_number.nil? || is_positive_number == (number >= 0)
          cumulative_sum += number
        else
          simpler_array << cumulative_sum
          cumulative_sum = number
        end
        is_positive_number = number >= 0
      end
      simpler_array << cumulative_sum
    end
def simplify_array ( array ) simpler_array = Array . new is_positive_number = nil cumulative_sum = 0 array . each do | number | if is_positive_number . nil? || is_positive_number == ( number >= 0 ) cumulative_sum += number else simpler_array << cumulative_sum cumulative_sum = number end is_positive_number = number >= 0 end simpler_array << cumulative_sum end
Sum all contiguous positive numbers
Sum all contiguous negative numbers
Returns an array with alternating postive and negative numbers
Sum all contiguous positive numbers Sum all contiguous negative numbers Returns an array with alternating postive and negative numbers
array