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.
fromitertoolsimportcombinations_with_replacementdefcombinations(s,t):# sort s and find all possible combinations & return the sorted combinationsreturn(["".join(x)forxinlist(combinations_with_replacement(sorted(s),t))])if__name__=='__main__':T=input().rsplit()s=str(T[0])t=int(T[1])print(*combinations(s,t),sep='\n')
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
itertools.combinations_with_replacement()
You are viewing a single comment's thread. Return to all comments →
Python