Created
July 18, 2017 16:54
-
-
Save asmega/ba95666e88917edf7a64f438617cef29 to your computer and use it in GitHub Desktop.
group into columns
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
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