itertools.permutations()

Sort by

recency

|

912 Discussions

|

  • + 0 comments
    from itertools import permutations
    def permutation(string):
        combinations = list(permutations(string[0], int(string[1])))
        for i in sorted(combinations):
            print("".join(i))
    				
    if __name__ == '__main__':
        S = input().split()
        permutation(S)
    
  • + 0 comments

    from itertools import permutations

    s,n = input().split() n = int(n) result = sorted(list(permutations(s,n)))

    for i in result: print(''.join(i))

  • + 0 comments
    from itertools import permutations
    
    if __name__ == '__main__':
        s, length = input().split()
        
        print('\n'.join([''.join(i) for i in permutations(sorted(s), int(length))]))
    
  • + 0 comments
    1. from itertools import permutations
      1. a,b = (input().upper()).split()
    2. b = int(b)
    3. a = "".join(sorted(a)) # return a string in lexicographic order
    4. ans = list(permutations(a,b))
    5. for i in ans:
    6. list(i)
    7. print("".join(i))
  • + 0 comments

    Here is the solution:

    from itertools import permutations s,k = input().split() res = sorted(permutations(s,int(k))) for i in res: print("".join(i))