def flatten_vertically(arrs)
      result = []
      arrs = arrs.map {|sub| sub.is_a?(Array) ? sub.dup : Array(sub)}
      until arrs.empty?
        arrs.reject! do |arr|
          result << arr.shift
          arr.empty?
        end
      end
      result
    end
def flatten_vertically(arrs)
      result = []
      arrs = arrs.map {|sub| sub.is_a?(Array) ? sub.dup : Array(sub)}
      until arrs.empty?
        arrs.reject! do |arr|
          result << arr.shift
          arr.empty?
        end
      end
      result
    end
Flattens the first level of nested arrays in `arrs`. Unlike
 `Array#flatten`, this orders the result by taking the first
 values from each array in order, then the second, and so on.

 @param arrs [Array] The array to flatten.
 @return [Array] The flattened array.