-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path08-Mini_Max_Sum.py
More file actions
41 lines (31 loc) · 877 Bytes
/
08-Mini_Max_Sum.py
File metadata and controls
41 lines (31 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
'''
Created on Tue Mar 01 2022
@author: Carlos Páez
'''
#
# Complete the `miniMaxSum` function below
#
# The function accepts INTEGER_ARRAY ass as parameter
#
def miniMaxSum(arr):
"""
Given an array of integers, find the minimum and maximum values that can be calculated by summing
exactly four of the five integers.
Then print the respective minimum and maximum values as a single line of two space-separated long
integers
:param arr: an array of 5 integers
"""
arr_sort = sorted(arr)
mini, max = 0, 0
i, j = 0, len(arr) - 1
if len(arr) > 5: pass
for _ in range(len(arr) - 1):
mini += arr_sort[i]
max += arr_sort[j]
i += 1
j -= 1
print(mini, max)
if __name__ == '__main__':
arr = list(map(int, input().rstrip().split()))
miniMaxSum(arr)