Discussing the structure of the lesson itself - stackoverwhoa!

'Cause I feel a little bit cheated! I understand the maths behind the powerset and how the binary system allows 2^N possible numbers for N binary digits, so why explain so much correlation, and pull me away from the whole recursion if you’re going to drop a “you’re not smart enough line”? :frowning:

Learn recursion python - stackoverwhoa

Here is the complete solution. You’re not expected to understand every line, just take in the level of complexity.

def power_set(set):
  power_set_size = 2**len(set)
  result = []

  for bit in range(0, power_set_size):
    sub_set = []
    for binary_digit in range(0, len(set)):
      if((bit & (1 << binary_digit)) > 0):
  return result

Okay first of all, this code doesn’t look THAT complex…
Secondly, I really don’t like examples that I am not supposed to understand… And surely I don’t understand this one, because the preceding explanation is very poor in terms of python code, such as:

set = ['a', 'b', 'c']
binary_number = "101"
# produces the subset ['a', 'c']
# 'b' is left out because its binary digit is 0

(It doesn’t actually do anything except creating two variables…)

Which finally brings me to case-study conclusion quote (which also could double as a subtitle to the whole intro of this lesson):

(I would love to rewrite this commend describing how much I liked both methods explained PROPERLY in order to make the comparison.)