Optimizing material use

Hi Guys
I have a bunch of linear materials that I’m trying to repurpose and cut to a specific length I need. Is there a way to optimize the data so i find the right combination of length to have limited offcuts? I’m thinking it’s something in the line of 1D packing I need but I have no idea where to start approaching this.

The inputs I’m imagining are:

  • list of lengths of pieces I need to be cut
  • list of length of materials I have

and for output:

  • length of materials used and length of pieces that gets cut out from each them
  • any pieces that didn’t fit into the available material(so that if I don’t have enough material I know how much more to get)

Any help is appreciated. Thank you in advance!
Reference.gh (3.2 KB)