I’ll save you the headaches and suggest that unless you are a programmer with a degree, or with a few years experience or have someone to mentor you on this it is not a path to take. I only noted it for others that would read this.
You may find the Chain of Thought prompting is enough to improve your results. I don’t plan to check it out for your case but if I were tutoring someone would take the time.
FYI for others
Cutting stock problem
In operations research, the cutting-stock problem is the problem of cutting standard-sized pieces of stock material, such as paper rolls or sheet metal, into pieces of specified sizes while minimizing material wasted. It is an optimization problem in mathematics that arises from applications in industry. In terms of computational complexity, the problem is an NP-hard problem reducible to the knapsack problem. The problem can be formulated as an integer linear programming problem. A paper machine...
Update (12/08/2023)
You might find my reply of interest. I would not expect the same level of result with code using constraints but if you find success let me know.