Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Loading Cargo by Jiyoqisv
from itertools import combinations
def checkio(data):
s=sum(data) # total load
min=abs(s-2*data[0]) # initialize with any combination
# both arms are equivalent, we only need to partition to the half of the size
for i in range(1,len(data)//2+1):
for c in combinations(data, i):
# left is sum(c), right is s-sum(c), so diff is |(s-sum(c))-sum(c)|
m=abs(s-2*sum(c))
if m
June 29, 2014