Merge the Tools!

Sort by

recency

|

2609 Discussions

|

  • + 0 comments

    def merge_the_tools(string, k): li=[] for i in range(0,len(string),k): temp="" for j in range(k): temp=temp+string[i+j] li.append(temp) dup=[] for i in li: temp="" for j in i: if j not in temp: temp=temp+j dup.append(temp) for i in dup: print(i)

  • + 0 comments

    def merge_the_tools(string, k): text = "" for i in string: text += i if len(text) == k: s = "".join(sorted(set(text), key=text.index)) print(s) text = ""

  • + 0 comments
    def merge_the_tools(string, k):
        text = ""
        for i in string:
            text += "".join(i)
            if len(text) == k:
                for i in range(len(text)):
                    s = "".join(sorted(set(text), key=text.index))
                print(s)
                text = ""
    
  • + 0 comments

    def merge_the_tools(string, k): # Iterate through the string in chunks of size k for i in range(0, len(string), k): # Extract the substring of length k s = string[i:i + k] # Remove duplicate characters while preserving order res = ''.join(dict.fromkeys(s)) print(res)

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

  • + 0 comments
    def merge_the_tools(string, k):
        
        n = len(string) // k
        aux = 0
        var = ''
        
        for i in range(len(string)):
            
            if aux == k:
                aux = 0
                var = set(list(var))
                print(''.join(var))
                var = ''
            aux += 1
            var += string[i]
        if aux == k:
            var = set(list(var))
            print(''.join(var))