HackerRank Python - itertools.combinations_with_replacement()
You are given a string S.
Your task is to print all possible size K replacement combinations of the string in lexicographic sorted order.
- # Enter your code here. Read input from STDIN. Print output to STDOUT
-
- from itertools import combinations_with_replacement
-
- s,k=input().split()
-
- for i in combinations_with_replacement(sorted(s),int(k)):
- print ("".join(i))