In this HackerRank Merge the Tools! the problem we have given a string and an integer. we need to do the factor of the following string and then remove the duplicate characters present in the factor and then print them.

HackerRank Merge the Tools! in python problem solution

 HackerRank Merge the Tools! in python problem solution

string, k = raw_input(""), input()
n = len(string)

def help_fun(items):
    seen = set()
    for i in items:
        if i not in seen:
            yield i
            seen.add(i)

while string:
    word = string[0:k]
    string = string[k:]
    
    print ''.join(help_fun(word))

Second solution

import fileinput

inputs = []

for line in fileinput.input():
    inputs.append(line)
    
k = int(inputs[1])
count = 0
str = ""

for ch in inputs[0]:
    if ch == ' ' or ch == '\n':
        continue
    if count % k == 0 and count != 0:
        print(str)
        str = ""
    if ch not in str:
        str += ch
    count += 1
print(str)