I have multiple nested loops that is equal to amount of data. For example, find the bar cutting combinations of 3 given lengths. so that the waste should not be longer than 1' after cutting in the 20' length rebar. so, I used 3 nested loops because there are 3 bar cuts. If I have 50 bar Cuts, then I will use 50 nested loops. So, what is the solution to this problem so no need to edit the source code. maybe double recursion? or any other algorithm. Thanks. Sample answer to given data below.
for (int a = 0; a < 50; a++){
for (int b = 0; b < 50; b++){
for (int c = 0; c < 50; c++){
double TL = a * BarCut[0] + b * BarCut[1] + c * BarCut[2];
double waste = 20 - TL;
//if (waste >= 0 && waste < 1 )
//Console.WriteLine($"{a}A, {b}B, {c}C, TL={TL}, waste = {waste:F2}");
}
}
}