Balancing two sets while items in one are unmovable

92 Views Asked by At

I'm working on a following problem: Given two sets containing jars, each of which is assigned a random weight (weight is a real number), find a way to balance two sets by weight, i.e. the difference in weight between two sets is minimal, given the following constraints:

  • It is impossible to move jars from the set with less weight
  • Not all jars from heavier set are movable
  • (Optional) the difference in number of jars between two sets is minimal

I think the problem is similar to partition problem, but not 100% sure. I don't expect the complete answer, so a suggestion to the potentially right direction is appreciated. Thanks.