Skip to content

Instantly share code, notes, and snippets.

@chyanju
Created January 18, 2016 02:23
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 chyanju/3676dcfefe719f082326 to your computer and use it in GitHub Desktop.
Save chyanju/3676dcfefe719f082326 to your computer and use it in GitHub Desktop.
Distributed Splitting Function, Splitting M into N pieces
"Distributed Splitting Function, Splitting M into N pieces"
function dSplitFast(M,N)
a = [floor(Int64,M/N)+(i<=M%N) for i=1:N]
b = unshift!([sum(a[1:j]) for j=1:N],0)
c = [p[1]+1:p[2] for p in[b[k:k+1] for k=1:N]]
return c
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment