itertools.combinations_with_replacement(iterable, r) Hacker Rank

 from itertools import combinations_with_replacement

A,B = input().split()
stringsorted= ''.join(sorted(A.upper()))
output =  ["".join(j) for j in combinations_with_replacement(stringsorted,int(B))]
print('\n'.join(output))

Comments

Popular posts from this blog

Mean, Var, and Std in numpy HackerRank

Min and Max in numpy HackerRank

Collections.deque() HackersRank Solution