0
I got a problem I can’t fix:
Given a string "aeiaaioooau"
, identify existing sequences and count your elements with PHP.
A sequence would be a
,e
,i
,o
and u
...
Example:
$s = "aeiaaioooau"
"aei"
is sequence of 3 elements, therefore sum + 3- afterward
"aa"
is not sequence,so it adds up to nothing- afterward
"iooo"
is sequence of 4 elements, therefore sum + 4- the next
"a"
don’t add up nothing for not being sequential- finally
"u"
is sequence one-element, sum + 1The elements being sequential
"aei+iooo+u" = 8
elements.
How to do this with PHP?
Hello. I don’t quite understand the proposition. Why "Aai" is not sequence but "iooo" is?
– Rohan
What is the logic? Why the last to is not considered a sequence, but u, yes? In the case of another word, example: abecedario, the result should be 4 or other value?
– Valdeir Psr
Is this a school exercise? You need, before applying these logics, to break the string to have the distinct elements in an array and then try to use it for each situation. Good luck.
– Leonardo Negrão
the logic is that a sequence is always 'a,e,i,o , u' , therefore aaaeiiiiioooou is a sequence as much as aeiou, but aaaaeiaaaaaou , has to ignore this chain of Aaaaa in order to be accounted for.
– José Darci Rodrigues Jr