mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2025-01-22 22:54:08 +03:00
15 lines
314 B
Python
15 lines
314 B
Python
|
from itertools import chain, combinations, permutations
|
||
|
|
||
|
|
||
|
def all_subsets(ss):
|
||
|
return chain(*map(lambda x: combinations(ss, x), range(0, len(ss) + 1)))
|
||
|
|
||
|
|
||
|
c = 0
|
||
|
|
||
|
for subset in all_subsets(list(range(1, 10))):
|
||
|
if sum(subset) == 10:
|
||
|
c += len(list(permutations(subset)))
|
||
|
print(subset)
|
||
|
print(c)
|