Looking for algorithm which will resolve my problem, i.e.
- Having a table with values: [6, 2, 3, 1]
- Get an average value per slice: 12/4 = 3
- Re-balance values in slice, i.e. I should get formulas something like: 1) 0, 2) 6-1, 3) 0, 4) 5-2. I.e. from highest value deduct amount need's for average. As result I will need to get slice [3, 3, 3, 3]
Thanks