This is going to sound like an academic problem, but I assure you it's not homework
.
TL;DR: Assume you have a piece of pipe that has some holes drilled in it. You have some other smaller diameter pieces of pipe that can be used as inserts to cover the holes. You can insert these from the right, left, or both the right and the left. What are the possible combinations, given the lengths of the inserts, that could be used to cover these holes.
Full version -- more details:
Assume you have a piece of PVC pipe some length, L. This piece of PVC may have some holes drilled in it that in certain situation you want covered. In order to cover these holes, you have combinations of slightly smaller diameter PVC pipes available that you can slide in. Now, based on where the holes are, you need to calculate which lengths of pipe to use.
This would be a very easy problem to solve if you had the constraint of only inserting from the left or the right. But, let's say you have a pipe of length L=40 inches, and you have holes at +18 and -18 inches from the center. It may be more efficient material wise to put in, say, one 7 inch piece from each side so you only use 14 inches of material, rather than a 38 inch piece (assuming you had an insert that length).
Of course, there are other constraints like time. It may be a lot quicker to put in one long piece than worry about saving material and putting in shorter pieces. But, I can filter out solutions based on those constraints. What I really need is, given inserts of lengths 7 inch, 14 inch, 22 inch, and 27 inch, what are the possible combinations that will cover up the holes in a given material. So, as an example.
PVC Pipe Length L=30, we will call the right edge 0, so with holes at +6 and +25 inches, a solution may be a 7 inch piece from the right, and 7 inch piece from the left. Another solution may be a 27 inch piece from the right and yet another solution just a 27 inch piece from the left.
You get the idea. Also, I figured the worst case scenario for number of pieces used was L/(shortest insert) assuming they were all inserted from the same side. This puts an upper bounds on the number of pieces that can be used. But, this lead to tons of possible solutions still, because we have 7 possible insert lengths. So, we put a constraint on it -- combinations must include 3 pieces or less. One other constraint is, when inserting from the right and the left, you can't have the inserts overlap. So, you can't use a 27 inch piece from the left and the right on a 30 inch PVC pipe piece. And finally, the sum of the lengths of the inserts used has to be less than the PVC pipe itself (i.e. no overhang).
So, I hope that was enough information. Curious if anyone can solve this; it is not an easy problem.