$ ./guess_the_languageProblem Solving — fill the blank
Problem Solving — fill the blank · hard · #310

What goes in the blank?

# all subsets: each item is either left out or taken
def subsets(xs):
    if not xs:
        return [[]]
    rest = subsets(xs[1:])
    return rest + [[xs[0]] + r for r in ____]

Answer: rest (also accepted: rest)

The subsets without xs[0] are rest; adding xs[0] to each of them gives the other half.
Play Problem Solving ▸