Thanks for the reviews.
I have change my code a little bit. I now check for 1 string and at the end I check for every word the three filters So I looks now like this: checkForbiddenParts: word "checks if a word contains some forbidden parts" ^ forbiddenWords anySatisfy: [ :forbidden | word includesSubstring: forbidden ] checkLessThen3Vowels: aString "checks if a words contains less then 3 vowels" ^ (aString count: #isVowel) < 3 checkOverLapping: aString "checks if a string has two overlapping characters" | result | result := aString asArray overlappingPairsCollect: [ :a :b | a ~= b ]. ^ result includes: true isNice: aCollection "checks if a word is nice according to the 3 filters" | answer | answer := aCollection reject: [ :word | (FindNiceStrings new checkForbiddenParts: word) | (FindNiceStrings new checkLessThen3Vowels: word) | (FindNiceStrings new checkOverLapping: word) not ]. ^ answer size But somewhere must be a bug because the answer the code given in too high. So I think I for a few hours/days busy to find out where the bug is. here are the 3 filters described : A nice string is one with all of the following properties:
Roelof Op 15-12-2018 om 09:37 schreef p...@highoctane.be:
|
- [Pharo-users] how to rewrite this to use a stream Roelof Wobben
- Re: [Pharo-users] how to rewrite this to use a str... Richard Sargent
- Re: [Pharo-users] how to rewrite this to use a... Roelof Wobben
- Re: [Pharo-users] how to rewrite this to u... Richard Sargent
- Re: [Pharo-users] how to rewrite this to use a str... Richard O'Keefe
- Re: [Pharo-users] how to rewrite this to use a... p...@highoctane.be
- Re: [Pharo-users] how to rewrite this to u... Roelof Wobben
- Re: [Pharo-users] how to rewrite this ... Roelof Wobben