Issue
I have a list of values that has a size of 24.
What I want to do is find the biggest combination using three values from the list. I only want to use three of the values, the highest ones possible.
So if I had a list that looked like:
vals_list = [5, 3, 5, 5, 5, 4, 2, 1, 2, 4]
My desired output would be 15, as it would take three of the '5' values in the list and sum them together. Is there any possible way to do this in python?
Solution
IIUC sorting values and extract last 3 values for top3, last sum them:
print (sum(sorted(vals_list)[-3:]))
15
Answered By - jezrael
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.