The power set of a set is the set of all its subsets. Write a function that, given a set, generates its power set.

For example, given the set {1, 2, 3}, it should return {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}.

You may also use a list or array to represent a set.

def print_set(set) set.length.times do |i| j = 0 print "{" while j<=i do print set[j] j+=1 end print "}" print "\n" end end def power_set(set) p_set_size = set.length puts "{}" p_set_size.times do print_set(set) set.shift() #removes first element from the set end return nil end power_set([1,2,3])

*Share and support! ❤️Also, see : ***Developer terms that every developer should know**