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.
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)
`
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 →
A simple Core Python code with descriptions (as comments), and without using any inbuilt function or module:
` def merge_the_tools(string, k):
if name == 'main': string, k = input(), int(input()) merge_the_tools(string, k) `