On Mon, Dec 10, 2018 at 8:52 AM Roelof Wobben <r.wob...@home.nl> wrote:

> Hello,
>
> is there a way I can check if a word has 2 the same chars after each other
> I was hoping that '#groupby could help me but that one sorts
> so abba the aa is found
> or do I have to use a stream for that
>
> could I then also use that stream to check if a word contains 3 vowels ?
>

I'll start with this question first, since it is the easiest to discuss.
The brute-force approach would be to use #select: against the word to
extract all the vowels. But a better approach, would be to imagine what you
need and delegate it. So, we already have #select:, #reject, #detect:, and
#collect: as patterns. Imagine a new method called #count:, and implement
that. (For the purpose of the assignment, implementing #count: is probably
overkill, unless you have many, many words to check.)


Now, back to the first question. You want to iterate through the word
"pairwise", where you examine each successive pair of letters.
So, you want to iterate from 1 through n-1 and check whether the letter at
the index is the same as the letter at the index + 1.
That should be enough to get you going.


> I ask also on the discord app but no answer for a long time
>
>
> Regards,
>
> Roelof
>
>

Reply via email to