Skip to content

Instantly share code, notes, and snippets.

@kavilivishnu
Created August 27, 2020 19:23
Show Gist options
  • Save kavilivishnu/44236cf32bbc64bd44d6a44aea5db61f to your computer and use it in GitHub Desktop.
Save kavilivishnu/44236cf32bbc64bd44d6a44aea5db61f to your computer and use it in GitHub Desktop.
Minimizing the sum of given input
'''
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