-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mini-Max-Sum.py
43 lines (34 loc) · 954 Bytes
/
Mini-Max-Sum.py
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
42
43
#Given five positive 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.
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'miniMaxSum' function below.
#
# The function accepts INTEGER_ARRAY arr as parameter.
#
def miniMaxSum(arr):
arr.sort()
min = 0
max = 0
for x in arr:
if x > arr[0]:
# print(x)
max +=x
if x < arr[0]:
# print(x)
max += x
elif x < arr[len(arr)-1]:
min += x
if x == arr[0]:
for i in range(0,len(arr)-1):
min += arr[i]
max += arr[i]
print(min, max)
if __name__ == '__main__':
arr = list(map(int, input().rstrip().split()))
miniMaxSum(arr)