secret
Created

  • Download Gist
solution1.rb
Ruby
1 2 3
a.each_slice(2).map.with_index do |as, i|
i.odd? ? as.map(&:reverse).reverse : as
end.map { |a| a.size > 1 ? a[0].zip(a[1]) : a }.flatten
solution2.rb
Ruby
1 2 3
a.each_slice(2).map.with_index do |as, i|
i.odd? ? as.map(&:reverse).reverse : as
end.map { |a, b=[]| a.zip(b) }.flatten.compact

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.