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 .
Sample Input
AABCAAADA
3
Sample Output
AB
CA
AD
Explanation
String is split into equal parts of length . We convert each to by removing any subsequent occurrences non-distinct characters in :
We then print each on a new line.
def merge_the_tools(string, k):
# your code goes here
for j in range(0,len(string),k):
s=""
for i in range(j,k+j):
s+=string[i]
s1=""
for i in s:
if(i not in s1):
s1+=i
print(s1)
if __name__ == '__main__':
string, k = input(), int(input())
merge_the_tools(string, k)
0 Comments