-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathmini-max-sum.py
55 lines (38 loc) · 1.33 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
'''
problem--
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.
For example, arr=[1,3,5,7,9]. Our minimum sum is 1+3+5+7=16 and our maximum sum is 3+5+7+9=24. We would print
16 24
Function Description--
Complete the miniMaxSum function in the editor below. It should print two space-separated integers on one line: the minimum sum and the maximum sum of 4 of 5 elements.
miniMaxSum has the following parameter(s):
arr: an array of 5 integers
Input Format--
A single line of five space-separated integers.
Constraints--
1<arr[i]<=10^9
Output Format--
Print two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly four of the five integers. (The output can be greater than a 32 bit integer.)
Sample Input---
1 2 3 4 5
Sample Output--
10 14
'''
#code here
#!/bin/python3
import math
import os
import random
import re
import sys
def miniMaxSum(arr):
l1=[]
for i in arr:
x=-i
for j in arr:
x+=j
l1.append(x)
print(min(l1),max(l1))
if __name__ == '__main__':
arr = list(map(int, input().rstrip().split()))
miniMaxSum(arr)