def strip_unneeded(bkts, sufficient_funds):
 bkts = sorted(bkts, key=(lambda bkt: bkt.value))
 for i in range(len(bkts)):
  if (not sufficient_funds(bkts[(i + 1):])):
   return bkts[i:]
 return bkts

def strip_unneeded ( bkts , sufficient_funds ) : bkts = sorted ( bkts , key = ( lambda bkt : bkt . value ) ) for i in range ( len ( bkts ) ) : if ( not sufficient_funds ( bkts [ ( i + 1 ) : ] ) ) : return bkts [ i : ] return bkts
remove buckets that are unnecessary in achieving the spend amount .