Skip to content

Instantly share code, notes, and snippets.

@TimLang
Last active December 28, 2015 15:39
Show Gist options
  • Save TimLang/7523727 to your computer and use it in GitHub Desktop.
Save TimLang/7523727 to your computer and use it in GitHub Desktop.
group array to range
values = [1,3,4,4,4,4,4,10,12,15,18]
bin_width = 5
ranges = 0.step((values.size/bin_width.to_f).ceil*bin_width, bin_width).each_cons(2).map { |s, e| Range.new(s, e, true) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment