You are viewing a single comment's thread. Return to all comments →
from itertools import combinations
a, b = input().split()
a =sorted(str(a))
A = []
x = int(b) for i in range(1, int(b)+1): A.append(list(combinations(a, i))) x += i
for j in range(int(b)): for i in range(len(A[j])): print(''.join(A[j][i]))
Seems like cookies are disabled on this browser, please enable them to open this website
itertools.combinations()
You are viewing a single comment's thread. Return to all comments →
from itertools import combinations
a, b = input().split()
a =sorted(str(a))
A = []
x = int(b) for i in range(1, int(b)+1): A.append(list(combinations(a, i))) x += i
for j in range(int(b)): for i in range(len(A[j])): print(''.join(A[j][i]))