Use python to optimize the rebar lost in construction.
Hello everyone, I'm a python beginner. I want to improve my coding skill so I try to use python to help my work.The following problem is bar cut list. It use in construction business. The rebar length is 10 meter each and We have to cut to length follow the order.We have to find the sequence of each Rebar Mark.I.E. We should cut bar No. 439(7350mm) then use it's scrap as rebar No.410 (2650mm) or We might cut bar no.443(6950mm) then no.410(2650mm) this would left the scrap 400mm.The less scrap on rebar the less rebar We have to order.The goal is to minimize rebar scrap on bar cut list.How should I create a logic follow this Idea?I have attached the link to csv file in case you want to try it.Thanks in advance.  
[https://drive.google.com/file/d/1vxJXX8jmEoumwA08x8UtVyBCjSDpyldu/view?usp=sharing](https://drive.google.com/file/d/1vxJXX8jmEoumwA08x8UtVyBCjSDpyldu/view?usp=sharing)

https://preview.redd.it/tm23n32zp4u81.png?width=450&amp;format=png&amp;auto=webp&amp;s=252b11688408922e06d0192bc52f2a415319124f