Uh oh!
There was an error while loading. Please reload this page.
Changes the code To return the list in dynamic_programming/subset_generation.py - #10191
Conversation
for more information, see https://pre-commit.ci
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Christian Clauss <cclauss@me.com>
…xingIssuereturntupple # Conflicts: # dynamic_programming/subset_generation.py
for more information, see https://pre-commit.ci
…xingIssuereturntupple # Conflicts: # dynamic_programming/subset_generation.py
for more information, see https://pre-commit.ci
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Christian Clauss <cclauss@me.com>
| arr = [10, 20, 30, 40, 50] | ||
| print_combination(arr, len(arr), 3) | ||
| # This code is contributed by Ambuj sahu | ||
| print(f"{subset_combinations_dp(elements=[10, 20, 30, 40], n=2) = }") |
There was a problem hiding this comment.
subset_combinations_dp() should work the same way as itertools.combinations(). It should present the same sort order and raise the same exceptions.
| print(f"{subset_combinations_dp(elements=[10, 20, 30, 40], n=2) =}") | |
| fromitertoolsimportcombinations | |
| foritems, nin ( | |
| ([10, 20, 30, 40], 2), ([1, 2, 3], 1), ([1, 2, 3], 3), ([42], 1), | |
| ([6, 7, 8, 9], 4), ([10, 20, 30, 40, 50], 1), ([1, 2, 3, 4], 2), | |
| ([1, 'apple', 3.14], 2), (['single'], 0), ([], 9) | |
| ): | |
| actual=subset_combinations_dp(items, n) | |
| expected=list(combinations(items, n)) | |
| assertactual==expected, f"items, n: {actual} != {expected}" | |
| print(f"{subset_combinations_dp(elements=[10, 20, 30, 40], n=2) =}") |
There was a problem hiding this comment.
I have changed the code now code giving the list sorted order
There was a problem hiding this comment.
itertools.combinations([1, 'apple', 3.14], 2)
…xingIssuereturntupple
for more information, see https://pre-commit.ci
…xingIssuereturntupple
for more information, see https://pre-commit.ci
…xingIssuereturntupple
cclauss
left a comment
There was a problem hiding this comment.
Thanks for going the extra mile on this one... It is a nice upgrade!
AasheeshLikePanner
commented
Oct 16, 2023
Really challenging and enjoyable. I fix one bug, then two errors comes. It's kind of frustrating, but worth the time. |
cclauss
commented
Oct 16, 2023
Sounds like software engineering to me. ;-) |
Describe your change:
Changes the code to return the tuples. So, we can add doctests in it after it. Change the whole code now code using dynamic programming as it header says
Checklist:
Change Code to return tuple in dynamic_programming/subset_generation.py #10189