Deviding N(1,2,3,..,N) part from numeric list as summation of each values(don't sorted) has highest as possible.

Nuen9 amornsak.nak at gmail.com
Mon Oct 10 11:20:39 EDT 2016


เมื่อ วันจันทร์ที่ 10 ตุลาคม ค.ศ. 2016 21 นาฬิกา 31 นาที 25 วินาที UTC+7, Steve D'Aprano เขียนว่า:
> On Tue, 11 Oct 2016 12:38 am, amornsak.nak at gmail.com wrote:
> 
> > I have a list is
> > 
> > land = [10,20,30,40,110,50,18,32,5]
> > 
> > and I want to find each values of summation (don't sorted values in list)
> > as It has highest as possible
> > 
> > example.
> > 
> > I want to dividing N=3 part from list as above and divieded each part has
> > highest values that as possible. *** (don't sorted values in list)
> > 
> > first part has values is = 10, 20, 30, 40
> > summation = 10+20+30+40 = 100
> 
> Why do you add four numbers? Why not add all the numbers?
> 
> 10+20+30+40+110+50+18+32+5 = 315
> 
> > second part has values is = 110
> > summation = 110
> 
> Why do you only take one number?
> 
> 
> > and third part has values is = 50, 18, 32, 5
> > summation = 105
> 
> Why do you take four numbers?
> 
>  
> > that 100, 110 and 105 is highest values as possible in list by dividing
> > N=3 part.
> 
> I do not understand, what do you mean "dividing N=3 part"?
> 
> Could you do this?
> 
> [10,20,30,40,110,50,18,32,5]
> 
> split into three lists:
> 
> [10,20,30,40,110,50,18], [32], [5]
> 
> Or these three lists:
> 
> [10], [20,30,40,110,50,18], [32,5]
> 
> Or these three lists:
> 
> [10,20,30], [40,110,50], [18,32,5]
> 
> How do you split the list into three?
> 
> 
> 
> 
> 
> 
> -- 
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.

I'm sorry for my English language. 

OK, I have list = [10,20,30,40,110,50,18,32,5] and want to find three values of summation from my list by split any way list but three values of summation has closely
example.
[10,20,30], [40,110,50], [18,32,5] = 60, 200, 55 -> it is not closely
*** 60 = 10+20+30, 200 = 40+110+50, 18+32+5 = 55
and [10], [20,30,40,110,50,18], [32,5]  = 10, 268, 37 -> and it is not closely
and [10,20,30,40],[110],[50,18,32,5] = 100,110,105 -> it's closely

The Really answers that I want is [10,20,30,40],[110],[50,18,32,5] = 100,110,105 from list[10,20,30,40,110,50,18,32,5]

And I don't know what I have to explain for my questions in English because My English so bad T_T

Thank you for reading my text

(;



More information about the Python-list mailing list