Inspired by Is it double speak?, I devised a harder challenge. Given a string, determine if the string is n-speak, for any \$n\geq 2\$.
N-speak is defined by repeating each letter \$n\$ times. With \$n = 4\$, the string
Hello is transformed to
HHHHeeeelllllllloooo. Your goal is to figure out if the input is a valid output for any n-speak transformation.
It should be noted that any sentence which is valid n-speak, for \$n = 2k\$, is also valid k-speak. Thus, the hard parts to solve will be odd values of \$n\$.
A string consisting of at least 2 characters. Input could also be a list of characters. Input is case sensitive.
Truthy if the string is n-speak,
HHeelllloo,, wwoorrlldd!! TTTrrriiipppllleee ssspppeeeaaakkk QQQQuuuuaaaaddddrrrruuuupppplllleeee ssssppppeeeeaaaakkkk 7777777-------ssssssspppppppeeeeeeeaaaaaaakkkkkkk 999999999 aaaabb aaaaaaaabbbbcc aaaaabbbbb @@@
If you want to generate additional truthy cases, you can use this MathGolf script. Place the string within the quotation marks, and the value of \$n\$ as the input.
Hello, world! TTTrrriiipppllleee speak aaaaaaaaaaaaaaaab Ddoouubbllee ssppeeaakk aabbab aaaabbb a (does not need to be handled) (empty string, does not need to be handled)
Of course, since this is code golf, get ready to trim some bytes!