Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def arrayConversion(inputArray)
- x = 1
- output = Array.new
- tmp = Array.new
- output = inputArray
- while (output.length > 1)
- if x % 2 != 0 then
- y = 0
- z = 0
- while (y < output.length - 1)
- tmp[z] = output[y] + output[y + 1]
- z = z + 1
- y = y + 2
- end
- output = tmp
- end
- if x % 2 == 0 then
- y = 0
- z = 0
- while (y < output.length - 1)
- tmp[z] = output[y] * output[y + 1]
- z = z + 1
- y = y + 2
- end
- output = tmp
- end
- x = x + 1
- tmp = Array.new
- end
- return output[0]
- end
Advertisement
Add Comment
Please, Sign In to add comment