Created
March 5, 2018 22:34
-
-
Save carturoch/91ad0807166dd7c679a9c8c4e50b8ee4 to your computer and use it in GitHub Desktop.
Nicer solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sums(list, interval) | |
list | |
.each_slice(interval) | |
.to_a | |
.map { |sublist| sublist.reduce :+ } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment