A string of characters repeats if it contains two consecutive substrings that are equivalent.
For example, 2034384538452
repeats as it contains 3845
twice, consecutively.
Therefore, your challenge is to decide whether a string contains a repeating substring. You may take the input as a string or an array of characters.
You will never receive an empty input, and the length of the substring (if it exists) may be 1 or more.
I use 1
and 0
here as my truthy and falsy values, but you may use different values, as long as they are truthy and falsy in your language.
Examples:
abcab -> 0
bdefdefg -> 1
Hello, World! -> 1
pp.pp/pp -> 1
q -> 0
21020121012021020120210121020121012021012102012021020121012021020120210121020120210201210120210121020121012021020120210121020121012021012102012021020121012021012102012101202102012021012102012021020121012021020120210121020121012021012102012021020121012021020120210121020120210201210120210121020121012021020120210121020120210201210120210201202101210201210120210121020120210201210120210121020121012021020120210121020121012021012102012021020121012021020120210121020120210201210120210121020121012021020120 -> 0
(The last example was generated from the amount of ones between each zero in the Thue-Morse sequence)