![]() ![]() MaxPac = LAMBDA(items, benefits, weights, limit,, LET( The question for the community: Can you conceptualize an easier way to do this? Formula-based solutions only, So I went with the recursive call option: =LET(results,TOCOL(BYROW(CombinMatrix,Solve),2),WRAPROWS(results,4,"")) It strings together the results in each cell. This function checks the CombinMatrix and totals up the Benefit and Weight for each combination. The way I see an 0 1 Knapsack is essentially generating COMBIN results and then determining which combination is the greatest benefit without going over the capacity.įirst, I created the 'Shuffle' function which takes a value produced from SEQUENCE and excludes any numbers >5 (total number of items) and removes values where a number repeats (e.g. That challenge was all about generating the COMBINA results. LAMBDA Halloween Challenge - Microsoft Community Hub I went back to a previous project's technique: I considered generating a value matrix (array of arrays limitation - MAKEARRAY could only go so far) and creating a recursive Lambda (I couldn't conceptualize one and I didn't think it would be efficient memory-wise). WikipediaĪfter studying 0 1 Knapsack Problems (A given item may only be selected once) and the techniques used to solve them, I sought to build formulas to solve a standard problem consisting of 5 items with various weights and benefits. Given a set of items, each with a weight and a value, determine which items to include in the collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |