CS4HS Summer Program for HS Teachers
July 2011
Problem 1
Root of a string

The root of string S is a shortest string T such that S=TTTTT...T. That is, you can obtain S by concatenating T with itself many times.

The input file DATA1.txt will contain 5 lines, each line having one non empty string over the alphabet a,b,c,...,z.

The output file OUT1.txt will contain 5 lines. Each line contains the root of the corresponding line in DATA1.txt.

Sample Input (only first 3 shown):
 
bbbbbbbbbbbb
abcddeffab
ataaattaataaattaataaattaataaatta
		        
Sample Output (only first 3 shown):
 
b
abcddeffab
ataaatta