[ [ [
[ GramChecker new
    isIsogramBag: 'ALTRUISME'] bench '99,720 per second'
 ] ] ]

[ [ [
[ GramChecker new
    isIsogram2Dict: 'ALTRUISME'] bench  '137,937 per second'
]]]

[ [ [
[ GramChecker new
    isIsogramSet: 'ALTRUISME'] bench  '390,887 per second'
]]]

[ [ [
[ GramChecker new
    isIsogramHenrik: 'ALTRUISME'] bench  '570,193 per second'
]]]


I will transform that as method extension and send the code around.

Then I will try pangram :)



Le 11/11/16 à 00:23, Henrik Nergaard a écrit :
String>>isIsogram

        1 to: self size -1 do: [ :ix |
                (self
                        findString: (self at: ix) asString
                        startingAt: ix +1
                        caseSensitive: false
                ) ~~ 0 ifTrue: [ ^ false ]      
        ].

        ^ true

-----Original Message-----
From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of 
Sven Van Caekenberghe
Sent: Thursday, November 10, 2016 11:10 PM
To: Any question about pharo is welcome <pharo-users@lists.pharo.org>
Subject: Re: [Pharo-users] Little challenges for a friday evening

[ :string | string size = string asSet size ] value: 'Pharo'.

true
[ :string | string size = string asSet size ] value: 'Pharoo'.

false
String>>#isIsogram
   ^ self size = self asSet size

?

On 10 Nov 2016, at 22:19, stepharo <steph...@free.fr> wrote:

Hi

I'm checking how I would implement an isogram checker

'Pharo' isogram

true
because it contains only single letter.

I got a stupid bag drivent implementation but I will do another better and 
faster.

Stef

PS: after I will do anagram and pangram to have the family of gram checks (this 
is for a book).







Reply via email to