-
-
Save Dbhardwaj99/4992268bd13ff759fa25b5fa7e6877ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sumNdifference(array): | |
j = 1 | |
array = sorted(array) | |
array = array[::-1] | |
while (true)): | |
diff = array[len(array)-1] | |
other = sum(array[j:]) | |
if array[0]-other > 0: | |
diff = array[0]-other | |
break | |
else: | |
j = j+1 | |
answer = [sum(array), diff] | |
return answer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks dope,well thought out code,great use of functions