Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ciag = [1,2,-5,7]
- sums = []
- i = 0
- zakres = 1
- loop do
- break if zakres > ciag.size-1
- if i + zakres > ciag.size
- zakres += 1
- i = 0
- end
- sum = 0
- for j in i..i+zakres-1
- sum += ciag[j].to_i
- end
- sums << sum
- i += 1
- end
- puts sums.inspect
- ## Output
- [1, 2, -5, 7, 3, -3, 2, -2, 4, 5]
Add Comment
Please, Sign In to add comment