Created
August 27, 2020 19:23
-
-
Save kavilivishnu/44236cf32bbc64bd44d6a44aea5db61f to your computer and use it in GitHub Desktop.
Minimizing the sum of given input
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
''' | |
Minimise the sum | |
''' | |
import time | |
t1 = time.process_time() | |
a = [] | |
for i in range(len(a)-1): | |
b = max(a) | |
c = b // 2 | |
a.append(c) | |
a.remove(b) | |
final = a | |
The sum() is used to get the sum of total elements in the list | |
print("Min sum " + "-", sum(final)) | |
t2 = time.process_time() | |
print(t1) | |
print(t2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment