From 64a25f98f1f0938b2e14dcfae0404faf2cb9dfe1 Mon Sep 17 00:00:00 2001 From: Gauravsaha-97 Date: Sun, 4 Oct 2020 09:43:43 +0530 Subject: [PATCH] Added 'minmax.py' file --- minmax.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 minmax.py diff --git a/minmax.py b/minmax.py new file mode 100644 index 0000000..28cfdcb --- /dev/null +++ b/minmax.py @@ -0,0 +1,21 @@ +# Problem Statement: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. + + +def min_maxSum(arr): + sum = 0 + max = 0 + min = 9999999999999999999 + n = len(arr) + for i in range(n): + sum+=arr[i] + min = min(min, arr[i]) + max = max(max, arr[i]) + + print(sum-max, sum-min) + + if __name__ == "__main__": + arr = list(map(int, input().rstrip().split())) + min_maxSum(arr) + + +