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.
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)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Merge the Tools!
You are viewing a single comment's thread. Return to all 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)