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

Steve D'Aprano steve+python at pearwood.info
Mon Oct 10 10:31:07 EDT 2016


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.




More information about the Python-list mailing list