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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Python
  3. Itertools
  4. itertools.permutations()
  5. Discussions

itertools.permutations()

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 723 Discussions, By:

recency

Please Login in order to post a comment

  • barmal_1992
    16 hours ago+ 0 comments

    from itertools import permutations

    s, k = input().split()

    out = list(map(lambda x: "".join(x), list(permutations(s, int(k)))))

    out.sort()

    print(*out, sep="\n")

    0|
    Permalink
  • tusharsrivastva1
    6 days ago+ 0 comments

    Very pythonic but not very readable

    from itertools import permutations
    s,k = input().split()
    print('\n'.join(sorted([''.join(i) for i in permutations(s,int(k))])))
    
    0|
    Permalink
  • zagadeomkar18
    1 week ago+ 0 comments
    from itertools import permutations
    
    S,k= input().split()
    li=list(permutations(S,int(k)))
    for i in sorted(li):
        print("".join(i))
    
    0|
    Permalink
  • subhansami078
    1 week ago+ 0 comments
    from itertools import permutations
    A=input().split()
    l=A[0]
    r=int(A[1])
    f=sorted(list(permutations(l,r)))
    for _ in f:
        print("".join(_))
    
    0|
    Permalink
  • jovanjoviemmanu1
    2 weeks ago+ 0 comments

    Enter your code here. Read input from STDIN. Print output to STDOUT

    from itertools import permutations

    input1 = input().split() string = input1[0] n = int(input1[1]) perms = sorted([''.join(perm) for perm in permutations(string, n)])

    for perm in perms: print(perm)

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy