Skip to content

Conversation

@eveem
Copy link

@eveem eveem commented Oct 17, 2018

#3

@@ -0,0 +1,20 @@
def isSubsetSum (items, length, summ):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide the comment stating what does the module/function do. Also, include the doctest in the comments.
Doctest reference - https://docs.python.org/2/library/doctest.html

if (items[length - 1] > summ):
return isSubsetSum(items, length - 1, summ);

return isSubsetSum(items, length - 1, summ) or isSubsetSum(items, length - 1, summ - items[length - 1])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the code runs in an exponential time. Please try to optimize using Dynamic programming.


return isSubsetSum(items, length - 1, summ) or isSubsetSum(items, length - 1, summ - items[length - 1])

if __name__ == '__main__':
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write the test cases in a separate file under the test directory. Check out other test cases which use the pytest to do the testing.
Pytest documentation - https://docs.pytest.org/en/latest/contents.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants