Hi George,
Here's the result:
>>> [list(group) for _,group in it.groupby("taaypiqee88adbbba")]
[['t'], ['a', 'a'], ['y'], ['p'], ['i'], ['q'], ['e', 'e'], ['8', '8'],
['a'], ['d'], ['b', 'b', 'b'], ['a']]
>>> [len(list(group)) for _,group in it.groupby("taaypiqee88adbbba")]
[1, 2, 1, 1, 1, 1, 2, 2
Thank you [EMAIL PROTECTED] <[EMAIL PROTECTED]>, George Sakkis <[EMAIL
PROTECTED]> and Aries Sun <[EMAIL PROTECTED]> for your
code contributions. I haven't tested them yet, but they look alright and enough
for me to work with.
Thanks to everyone else for your comments.
W. Brunswick.
--
http
Aries Sun <[EMAIL PROTECTED]> wrote:
>I used Python 2.4.1, the following are the command lines.
>But the reslut was still False. Is there anything wrong with below
>codes?
import itertools as it
def hasConsequent(aString, minConsequent):
> for _,group in it.groupby(aString):
>
"Aries Sun" <[EMAIL PROTECTED]> wrote:
> Hi George,
> I used Python 2.4.1, the following are the command lines.
> But the reslut was still False. Is there anything wrong with below
> codes?hasConsequent("taaypiqee88adbbba", 3)
All indentation was lost in your message, so I'm not quite sure; here
Hi George,
I used Python 2.4.1, the following are the command lines.
But the reslut was still False. Is there anything wrong with below
codes?
>>> import itertools as it
>>> def hasConsequent(aString, minConsequent):
for _,group in it.groupby(aString):
if len(list(group)) >
"Aries Sun" <[EMAIL PROTECTED]> wrote:
> I have tested George's solutions, it seems not complete. When pass (s,
> 3) to the function hasConsequent(), it returns the wrong result.
What are you talking about ? I get the correct answer for
>>> hasConsequent("taaypiqee88adbbba", 3)
True
George
--
I have tested George's solutions, it seems not complete. When pass (s,
3) to the function hasConsequent(), it returns the wrong result.
The following is my approach. The performence may be not so good. There
must be better ones.
>>> from re import findall
>>> def hasConsequent(aString, minConsequ
"Walter Brunswick" <[EMAIL PROTECTED]> wrote:
> Is there any way to [efficiently] iterate through a sequence of characters to
> find N [or more]
consecutive equivalent characters?
>
> So, for example, the string "taaypiqee88adbbba" would return 1 if the number
> (of consequtive
characters) suppl
Walter Brunswick wrote:
> Is there any way to [efficiently] iterate through a sequence of characters to
> find N [or more] consecutive equivalent characters?
>
> So, for example, the string "taaypiqee88adbbba" would return 1 if the number
> (of consequtive characters) supplied in the parameters
Walter Brunswick wrote:
> Is there any way to [efficiently] iterate through a sequence of characters to
> find N [or more] consecutive equivalent characters?
>
> So, for example, the string "taaypiqee88adbbba" would return 1 if the number
> (of consequtive characters) supplied in the parameters
10 matches
Mail list logo