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. Strings
  4. Merge the Tools!
  5. Discussions

Merge the Tools!

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 2406 Discussions, By:

recency

Please Login in order to post a comment

  • kmg2005
    1 week ago+ 1 comment

    Why does it work? I thought that a set doesn't keep the order of the elements.

    for i in range(0, len(string), k): print(''.join(list(set(string[i : i + k]))))

    0|
    Permalink
  • torben_mulitze1
    2 weeks ago+ 0 comments
    x = 0
    while x < len(string):
    		print("".join(list(dict.fromkeys(list(string[x:x + k])))))
    		x += k
    
    0|
    Permalink
  • 404NameNotFound
    3 weeks ago+ 0 comments

    another one liner solution (python 3.7+)

        print( *[ "".join( list( dict.fromkeys(string[i: i+k]) ) ) for i in range(0, len(string), k)], sep="\n")
    
    0|
    Permalink
  • abhishekrathod22
    3 weeks ago+ 0 comments

    l = len(string) // k print(l)

    for i in range(0, len(string), k):
        s = ''
        s += string[i]
        g=0
    
        for j in range(i + 1, i + k):
            c = False
            g += 1
            for h in range(g):
    
                if string[j:j + 1] != string[i + h]:
                    c = True
    
                else:
                    c = False
                    break
            if c:
                s += string[j:j + 1]
        print(s)
    
    0|
    Permalink
  • m_s_v_s98
    3 weeks ago+ 0 comments
    for i in range(int(len(string)/k)):
            m=''
            for j in range(k):
                if string[i*k+j] not in m:
                    m=m+string[i*k+j]
            print (m)
    
    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