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()
maxsum=0
minsum=0
for i in range(1,len(arr)):
maxsum+=arr[i]
for n in range(0,len(arr)-1):
minsum+=arr[n]
print(str(minsum)+" " +str(maxsum))
# Write your code here
if __name__ == '__main__':
arr = list(map(int, input().rstrip().split()))
miniMaxSum(arr)
Comments
Post a Comment