Rep-string: Difference between revisions

Content deleted Content added
→‎Tcl: Added two test patterns and output
m Clarify task description & add format magic
Line 3:
 
For example, the string <code>'10011001100'</code> is a rep-string as the leftmost four characters of <code>'1001'</code> are repeated three times and truncated on the right to give the original string.
 
Note that the requirement for having the repeat occur two or more times means that the repeating unit is ''never'' longer than half the length of the input string.
 
The task is to:
* Write a function/subroutine/method/... that takes a string and returns an indication of if it is a rep-string and the repeated string. (Either the string that is repeated, or the number of repeated characters would suffice).
* Use the function to indicate the repeating substring if any, in the following:
<dl><dd><pre>'1001110011'
'1110111011'
'0010010010'
Line 17 ⟶ 19:
'11'
'00'
'1'</pre></dl>
* Show your output on this page.