We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
itertools.combinations()
itertools.combinations()
Sort by
recency
|
888 Discussions
|
Please Login in order to post a comment
from itertools import combinations
Read input
S, k = input().split() k = int(k)
Sort the string to ensure lexicographic order
S = ''.join(sorted(S))
Generate and print combinations for each length from 1 to k
for i in range(1, k + 1): for combo in combinations(S, i): print(''.join(combo))
from itertools import combinations
def permutation(): user_input = input() input_list = user_input.split() var1, k = input_list[0], int(input_list[1]) sorted_var1 = "".join(sorted(var1)) for size in range(1, k + 1): for combo in combinations(sorted_var1, size): print("".join(combo))
if name == "main": permutation()
Enter your code here. Read input from STDIN. Print output to STDOUT
from itertools import product import itertools import sys
input_data = sys.stdin.read().strip()
A, B = input_data.split() B = int(B)
A_sort = ''.join(sorted(A))
''''''
for j in A_sort: print(j)
for x in range(2, B+1): perm_set = itertools.combinations(A_sort,x) for i in perm_set: print(''.join(i))
from itertools import combinations
st = input().split()
s = st[0]
k = int(st[1])
sorted_string = sorted(s)
for i in range(1, k+1):
for combo in combinations(sorted_string, i):