Merge the Tools!

Sort by

recency

|

2618 Discussions

|

  • + 0 comments
    count = len(string) // k
    
    for i in range(count):
        sub_s = ""
        for j in range(i*k,(i+1)*k):
            if string[j] not in sub_s:
                sub_s+=string[j]
                print(string[j],end="")
        print()
    
  • + 0 comments
    1. import textwrap
      1. def merge_the_tools(string, k):
    2. if(len(string)%k==0):
    3. t_string = textwrap.wrap(string,k)
    4. u_string=[]
    5. for i in t_string:
    6. s=""
    7. for j in i:
    8. if(j not in s):
    9. s=s+j
    10. u_string.append(s)

      print("\n".join(u_string))  
      
  • + 0 comments

    It is a little lengthy but worked for me

    def merge_the_tools(string, k): # your code goes here st = string sub_string_list = [] for i in range(int(len(st)/k)): sub_string = "" count = i for j in range(k): sub_string += st[count*k + j] sub_string_list.append(sub_string)

    for i in range(len(sub_string_list)):
        string_dict = {}
        formatted_str = ""
        for j in range(k):
            if sub_string_list[i][j] not in string_dict:
                formatted_str += sub_string_list[i][j]
                string_dict[sub_string_list[i][j]] = 1
        sub_string_list[i] = formatted_str
    for i in sub_string_list:
        print(i)
    
  • + 2 comments
    def merge_the_tools(string, k):
        for substring in range(0, len(string), k):
            print(''.join(dict.fromkeys(string[substring : substring + k])))
    
    if __name__ == '__main__':
        string, k = input(), int(input())
        merge_the_tools(string, k)
    
  • + 0 comments

    code

    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 = ""