function list_reps(string r) sequence replist = {} integer n = length(r) for m=1 to floor(n/2) do string s = r[1..m] if join(repeat(s,floor(n/m)+1),"")[1..n]=r then replist = append(replist,s) end if end for return replist end function constant tests = {"1001110011", "1110111011", "0010010010", "1010101010", "1111111111", "0100101101", "0100100", "101", "11", "00", "1"} for i=1 to length(tests) do printf(1,"%s\n",{tests[i]}) sequence replist = list_reps(tests[i]) if length(replist)=0 then printf(1,"not a rep-string.\n") else for j=1 to length(replist) do string rj = replist[j], pad = repeat(' ',length(rj)) printf(1,"%s%s\n",{pad,rj}) end for end if printf(1,"\n") end for