Help figuring a formula for my job
Solution 1:
This is a very well known, difficult problem, called the "bin packing problem". There is no known algorithm that would work efficiently for large numbers of pipes, but for reasonably small numbers it can be done in practice.
A reasonably good, though not always optimal, strategy is "first fit decreasing". Sort the desired output lengths in decreasing order, and cut each from the first tube where it will fit.