text of lowercase English letters and a positive integer divisor. The vowels are a, e, i, o and u; every other letter is a consonant.
Call a non-empty substring (a contiguous piece of the string) **balanced** if it has as many vowels as consonants and the number of vowels times the number of consonants is divisible by divisor.
Return how many balanced substrings there are. Pieces with the same letters at different positions count separately.text="moon", divisor=1 → 3
"mo" (1 vowel, 1 consonant), "on" (1 and 1) and the whole "moon" (2 and 2) all qualify. A divisor of 1 divides any product.
text="moon", divisor=4 → 1
For "mo" and "on" the product is 1·1 = 1, not divisible by 4. Only "moon" remains: 2·2 = 4.
text="xyz", divisor=1 → 0
text contains only lowercase English letterstext="moon", divisor=1
3
Run checks the first 3 tests in your browser. Submit checks all 91 tests on the server, hidden ones included.