Input Format
The first line contains a single string denoting .
The second line contains an integer, , denoting the length of each subsegment.
Constraints
  • , where  is the length of 
  • It is guaranteed that  is a multiple of .
Output Format
Print  lines where each line  contains string .

hackerrank merge the tools problem solution in python

Problem solution in python 2 programming language.

s = raw_input()
k = input()
chunks = len(s)/k

for index in xrange(chunks):
    merge = ""
    T = s[index*k : (index+1)*k]
    for ch in T:
        if ch not in merge:
            merge += ch
    print merge

Problem solution in python 2 programming language.

s = input()
k = int(input())
num_subsegments = int(len(s) / k)

for index in range(num_subsegments):
    # Subsegment string
    t = s[index * k : (index + 1) * k]
    
    # Subsequence string having distinct characters
    u = ""
    
    # If a character is not already in 'u', append
    for c in t:
        if c not in u:
            u += c

    # Print final converted string
    print(u)