You are viewing a single comment's thread. Return to all comments →
That's my version, I hope it helps!
from itertools import combinations start_letters, num = input().split(' ') start_letters = sorted(start_letters) letter_combination = []
for n in range(1,int(num)+1): list_combinations = sorted(list(combinations(start_letters, int(n)))) letter_combination.extend(list_combinations)
for i in letter_combination: print(*i, sep='')
Seems like cookies are disabled on this browser, please enable them to open this website
itertools.combinations()
You are viewing a single comment's thread. Return to all comments →
That's my version, I hope it helps!
from itertools import combinations start_letters, num = input().split(' ') start_letters = sorted(start_letters) letter_combination = []
for n in range(1,int(num)+1): list_combinations = sorted(list(combinations(start_letters, int(n)))) letter_combination.extend(list_combinations)
for i in letter_combination: print(*i, sep='')