Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def arrayConversion(a)
- sum = ->(x){x.each_slice(2).to_a.map{|x,y| x+y}}
- mul = ->(x){ x.each_slice(2).to_a.map{|x,y| x*y}}
- odd = true
- while a.size != 1 do
- a = sum.(a) if odd
- a = mul.(a) unless odd
- odd ? odd = false : odd = true
- end
- a[0]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement