Rep-string

From Rosetta Code
Revision as of 18:14, 10 May 2013 by rosettacode>Paddy3118 (Created page with "{{draft text}} Given a series of ones and zeroes in a string, define a repeated string as a string which is created by repeating a substring of the first N characters of the s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Draft text Given a series of ones and zeroes in a string, define a repeated string as a string which is created by repeating a substring of the first N characters of the string two or more times, truncated to the length of input string.

For example, the string '10011001100' is a repeated string as the leftmost four characters of '1001' are repeated three times and truncated on the right to give the original string.

The task is to:

  1. Write a function/subroutine/method/... that takes a strinmg and returns an indication of if it is a repeated string and the repeated string. (Either the string repeated, or the number of repeated characters would suffice).
  2. EMERGENCY - FLAT TYRE! BACK LATER.