Skip to content

Instantly share code, notes, and snippets.

@carturoch
Created March 5, 2018 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carturoch/91ad0807166dd7c679a9c8c4e50b8ee4 to your computer and use it in GitHub Desktop.
Save carturoch/91ad0807166dd7c679a9c8c4e50b8ee4 to your computer and use it in GitHub Desktop.
Nicer solution
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