Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- apportion(Shares, Ways) when is_integer(Shares) ->
- apportion(lists:duplicate(Ways, 0), Shares);
- apportion(Acc, 0) ->
- Acc;
- apportion(Acc, Remaining) ->
- N = Remaining rem length(Acc),
- [H|T] = lists:nthtail(N, Acc),
- apportion(lists:sublist(Acc, N) ++ [H+1|T], Remaining - 1).
Add Comment
Please, Sign In to add comment