diff options
Diffstat (limited to 'challenge-270/steven-wilson/python/ch-2.py')
| -rw-r--r-- | challenge-270/steven-wilson/python/ch-2.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/challenge-270/steven-wilson/python/ch-2.py b/challenge-270/steven-wilson/python/ch-2.py index aa703848be..9fcc5985f3 100644 --- a/challenge-270/steven-wilson/python/ch-2.py +++ b/challenge-270/steven-wilson/python/ch-2.py @@ -21,8 +21,13 @@ def distribute_elements(integers, x, y): 9 >>> distribute_elements([2, 3, 3, 3, 5], x=2, y=1) 6 + >>> distribute_elements([4, 4, 2, 6], x=3, y=1) + 4 + >>> distribute_elements([1, 1, 1, 6], x=3, y=1) + 10 ''' - max_int = max(integers) + integers = sorted(integers) + max_int = integers[-1] level_1_preferred = (x * 2 < y) cost = 0 positions = [i for i, v in enumerate(integers) if v < max_int] |
