Merge the Tools!

Sort by

recency

|

2653 Discussions

|

  • + 0 comments

    def merge_the_tools(string, k): for d in range(0,len(string),k): var = string[d: d+k] character ="".join(dict.fromkeys(var)) print(character)

    if name == 'main': string, k = input(), int(input()) merge_the_tools(string, k)

  • + 1 comment
    import textwrap
    from collections import OrderedDict
    
    def merge_the_tools(s, k):
        chunks = textwrap.wrap(s, k)
        for c in chunks:
            print("".join(OrderedDict.fromkeys(c)))
    
    def main():
        s, k = input(), int(input())
        merge_the_tools(s, k)
        
    if __name__ == "__main__":
        main()
    
  • + 0 comments
    def merge_the_tools(string, k):
        # your code goes here
        n = len(string)
        for i in range(0,n,k):
            word = ''
            for j in range(k):
                if string[i+j] not in word:
                    word+=string[i+j]
            print(word)
    
  • + 1 comment

    Hope it helps:

    def merge_the_tools(string, k):
        # your code goes here
        pos = 0
        output = ''
        for x in string:
            if pos == k:
                print(output)
                pos = 0
                output = ''
            if x not in output:
                output += x
            pos += 1
        print(output)
    
  • + 1 comment

    A simple Core Python code with descriptions (as comments), and without using any inbuilt function or module:

    ` def merge_the_tools(string, k):

    string_split= [string[characters : characters+k] for characters in range(0, len(string), k)]
    
    # ['ADA', 'AAB', 'CAA'] -- Otput of string_split will be something like this (assuming k=3 here)
    
    for word in string_split:
        l= []  
        for letter in word:        
            # print(letter) ['A', 'D' 'A']- 1st Iteration
            if letter not in l:
                l.append(letter) 
        # print(l) -- ['A','D']   ['A', 'B']   ['C', 'A'] 
        print("".join(l))
    

    if name == 'main': string, k = input(), int(input()) merge_the_tools(string, k) `