Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. def arrayConversion(a)
  2. sum = ->(x){x.each_slice(2).to_a.map{|x,y| x+y}}
  3. mul = ->(x){ x.each_slice(2).to_a.map{|x,y| x*y}}
  4. odd = true
  5. while a.size != 1 do
  6. a = sum.(a) if odd
  7. a = mul.(a) unless odd
  8. odd ? odd = false : odd = true
  9. end
  10. a[0]
  11. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement