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.permutations()
itertools.permutations()
Sort by
recency
|
902 Discussions
|
Please Login in order to post a comment
from itertools import permutations
s = input().split() x = s[0] y = int(s[1]) sorted_s = sorted(x)
for i in range(1,y+1): # for j in permutations(sorted_s,i): # for j in range(len(sorted_s)): # for j in permutations(sorted_s): for j in permutations(sorted_s,i+1): if i>=2: continue print(''.join(j))
from itertools import permutations def permutation(): user_input = input() input_list = user_input.split() var1, var2 = input_list[0], int(input_list[1]) k = list(permutations(var1, var2)) new_list = ["".join(i) for i in k] for element in sorted(new_list): print(element) if name == "main": permutation()
from itertools import permutations
def permut(s, k): s.upper() p_val = list(permutations(s, k)) p_val.sort() [print(''.join(x)) for x in p_val]
space_sep_input = input().split() string = (space_sep_input[0]).upper() k = int(space_sep_input[1]) permut(string, k)
Easy 3 liner. Could be two lines but that's ugly code lol