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):
#number of parts
cnt = len(string) // k
#list of parts
l = [string[i*k : (i+1) * k] for i in range(cnt)]
#process each part
for s in l:
print(''.join([ s[i] for i in range(k) if s[i] not in s[0:i] ]))
if name == 'main':
string, k = input(), int(input())
merge_the_tools(string, k)
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 →
def merge_the_tools(string, k): #number of parts cnt = len(string) // k #list of parts l = [string[i*k : (i+1) * k] for i in range(cnt)] #process each part for s in l: print(''.join([ s[i] for i in range(k) if s[i] not in s[0:i] ]))
if name == 'main': string, k = input(), int(input()) merge_the_tools(string, k)