Practical numbers: Difference between revisions

Content added Content deleted
(New draft task with Python solution)
 
m (→‎{{Header|Python}}: Typing ...)
Line 44: Line 44:
# %% Powerset
# %% Powerset


def powerset(s: List[int]) -> List[Tuple[int]]:
def powerset(s: List[int]) -> List[Tuple[int, ...]]:
"""powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3) ."""
"""powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3) ."""
return list(chain.from_iterable(combinations(s, r) for r in range(len(s)+1)))
return list(chain.from_iterable(combinations(s, r) for r in range(len(s)+1)))