- this.totalCostAuxStorage = Array(itemsLength).fill(undefined);
- console.log("===", itemsLength);
- let a = this.totalCostAux(items, itemsLength-1, lineWidth);
- console.log(this.lineCostStorage);
+ this.totalCostAuxStorage = Array(itemsLength).fill(null);
+
+ let a = Infinity;
+ for(var k=itemsLength-2; this.lineCost(items, k+1,itemsLength-1, lineWidthFixed) < Infinity; k--){
+
+ let tmp = this.totalCostAux(items, k, lineWidthFixed);
+
+ if (a > tmp){
+ this.prevNodes[itemsLength-1] = k
+ a = tmp;
+ }
+
+ }