Here's a recursive approach to getting all proper subsets of a set in Python:
main.py440 chars16 linesThe get_subsets function is a helper function that returns all possible subsets of a given set s. The get_proper_subsets function uses get_subsets to get all possible subsets, and then filters out the set s itself (which is not a proper subset).
We can use the code like this:
main.py89 chars4 lines
gistlibby LogSnag