Little problem(s) July 2022
|
07-04-2022, 11:11 PM
Post: #3
|
|||
|
|||
RE: Little problem(s) July 2022
I am not sure if this match the requirements.
Here is Lua's solution, which should be trivial to convert to Python Note: Lua index is 1-based; Python 0-based. Code: function f(lst, x) For index permutations instead of combinations, remove if prev > y then ... line lua> L1, L2 = {1,2,3,2,2,1}, 6 lua> f(L1, L2) -- L1 index combinations that sum to L2 1 2 3 1 2 4 6 1 2 5 6 1 3 4 1 3 5 1 4 5 6 2 3 6 2 4 5 3 4 6 3 5 6 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)