UPDATE : isaacg's Pyth submission is the winner!
String.prototype.repeat so that you can do
"Hello, World!Hello, World!Hello, World!"
as the output.
Your job is to write a function or a program in a language of your choice which detects if a string has been gone under such transformation.
i.e. The input string can be represented as an exact
n times repetition of a smaller string. The output (as function's return statement or STDOUT) should be truthy if the string can be or falsy if the string cannot be represented as a repetition of smaller string.
Some sample input:
"asdfasdfasdf" // true "asdfasdfa" // false "ĴĴĴĴĴĴĴĴĴ" // true "ĴĴĴ123ĴĴĴ123" // true "abcdefgh" // false
Note that the last input is false, thus
n should be greater than
- Write a function/program in any language to input (via function argument/command line args/STDIN) a string
- Return/Print truthy value if the given string is formed via an exact repetition of a smaller string, repeating at least twice.
- Maximum size of the input string is ideally Infinity
- String can have all possible ASCII characters
- This is a code-golf so smallest code in characters wins.