Guest User

Untitled

a guest
Feb 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. apportion(Shares, Ways) when is_integer(Shares) ->
  2. apportion(lists:duplicate(Ways, 0), Shares);
  3. apportion(Acc, 0) ->
  4. Acc;
  5. apportion(Acc, Remaining) ->
  6. N = Remaining rem length(Acc),
  7. [H|T] = lists:nthtail(N, Acc),
  8. apportion(lists:sublist(Acc, N) ++ [H+1|T], Remaining - 1).
Add Comment
Please, Sign In to add comment