On 10/10/2016 09:25 AM, Nuen9 wrote:
Hi!
Could it be, "Nuen9", that you would like to find a split where the
split sums are close to each other? In other words, you define the
number of splits (in your example: 3) and the algortihm should test all
possible combinations and select the split where the sum differences are
smallest.
Best,
Kimmo
Yes it is, I want example python code for finding my answers but I don't code
my answers. please help me.
Here's one way:
n=3
land = [10,20,30,40,110,50,18,32,5]
lsum = sum(land)
lavg = lsum/n
close = lavg/n
idx = 0
lnsums = [0]*n
ln=0
while idx < len(land) and ln<n:
lnsums[ln]+= land[idx]
idx += 1
if lnsums[ln] > lavg-close:
ln+=1
print lnsums
--
Emile
--
https://mail.python.org/mailman/listinfo/python-list