Skip to content

Instantly share code, notes, and snippets.

@asmega
Created July 18, 2017 16:54
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 asmega/ba95666e88917edf7a64f438617cef29 to your computer and use it in GitHub Desktop.
Save asmega/ba95666e88917edf7a64f438617cef29 to your computer and use it in GitHub Desktop.
group into columns
max = 10.to_f
cols = 3
target = (max/cols).ceil
(0..max).to_a.slice_before(target: target) do |i,state|
if i > state[:target]
state[:target] += state[:target]
true
else
false
end
end.to_a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment