A Needle in the Haystack

The program has to detect all occurences of the needle in the haystack. It should take the needle and the haystack as input, and output the positions of each occurence, as shown below.

Input

The input consists of a number of test cases. Each test case is composed of three lines, containing:

the length of the needle,
the needle itself,
the haystack.

Output

For each test case your program should output all positions of the needle's occurences within the haystack.

eg:
Input :
2
na
banananobano

output:
2
4

Comments

Post a Comment

Popular posts from this blog