Function to express power sets

Question

Create a function that generates the power set given a set of values.

For example, if you're given the following set:

  • set = {1, 2, 3}

Your function should the corresponding power set (note this can be a formatted as a list of lists):

  • power set = [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now