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
|
927 Discussions
|
Please Login in order to post a comment
The shortest code I could write…
from itertools import combinations
s, k = input().split() s = sorted(s) k = int(k)
for x in range(1, k + 1): for combo in combinations(s, x): print("".join(combo))