itertools.permutations()

Sort by

recency

|

939 Discussions

|

  • + 0 comments

    The shortest code I could think of…

    from itertools import *
    s, k = input().split()
    print('\n'.join(''.join(p) for p in permutations(sorted(s), int(k))))
    
  • + 0 comments
    from itertools import permutations
    
    inp = input().split()
    
    possibilities= list(permutations(inp[0], int(inp[1])))
    possibilities.sort()
    
    for i in possibilities:
        print(''.join(i))
    
  • + 0 comments

    from itertools import permutations

    input_list = list(input().split())

    permutation_length = int(input_list[1])

    permutation_list = (list(input_list[0]))

    permutation_list.sort()

    permutation_result = list(permutations(permutation_list,permutation_length)) x = 0 for i in range(len(permutation_result)): print("".join(permutation_result[x])) x+=1

  • + 0 comments

    from itertools import permutations from re import sub

    s, k = input().split() k = int(k)

    res = sorted(permutations(s, k))

    for p in res: word = "".join(p) print(sub(r'[^a-zA-Z0-9]', ' ', word))

  • + 0 comments

    from itertools import permutations

    S = input().split() string = str(S[0]) k = int(S[1])

    list1 = list(sorted(permutations(string,k)))

    for i in range(len(list1)): print(''.join(list1[i]))