Golf to find Boring numbers
Retina, 9 bytes
(.+)\1{4}
Verify all testcases! (slightly modified to run all testcases at once.)
05AB1E, 8 bytes
Code:
Œv¹y5×åO
Explanation:
Œ # Compute all substrings from the input.
v # For each substring.
y5× # Repeat the substring 5 times (42 × 5 = 4242424242).
¹ å # Check if it's in the input string.
O # Sum up the result. Non-boring numbers should give 0.
Truthy is non-zero and falsy is zero. Uses the CP-1252 encoding.
Try it online!
Java 8, 52 bytes
s->s.matches(".*(.+)\\1{4}.*")
Outgolfed this Java 8 answer with a direct String#matches
.
Explanation:
Try it here.
s-> // Method with String parameter and boolean return-type
s.matches( // Return whether the entire String matches the following regex:
".* // 0 or more leading characters
(.+)\\1{4} // group of 1 or more characters, repeated 5 times
.*") // 0 or more trailing characters