[EMAIL PROTECTED] wrote:
> Nevermind, I didn't understand the problem/question... Sorry.
>
> Bye,
> bearophile
>
Really? Your solution looks fine to me.
In any case, here's an alternative approach to the (based on the same
understanding of the problem as bearophile's, but with the additional
David Hirschfield <[EMAIL PROTECTED]> writes:
>Here's the problem: Given a list of item names like:
>apple1
>apple2
>apple3_SD
>formA
>formB
>formC
>kla_MM
>kla_MB
>kca_MM
>which is a subset of a much larger list of items,
>is there an efficient algorithm to create condensed forms that match
>t
[EMAIL PROTECTED] a écrit :
> Nevermind, I didn't understand the problem/question... Sorry.
actually, I think *you* got it right.
--
http://mail.python.org/mailman/listinfo/python-list
Nevermind, I didn't understand the problem/question... Sorry.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers a écrit :
> David Hirschfield a écrit :
>
>> Here's the problem:
(snip)
>>
>> is there an efficient algorithm to create condensed forms that match
>> those items,
Sorry, answered to fast... Well, at least you have a way to test the
algo !-)
--
http://mail.python.org/mailm
David Hirschfield a écrit :
> Here's the problem: Given a list of item names like:
>
> apple1
> apple2
> apple3_SD
> formA
> formB
> formC
> kla_MM
> kla_MB
> kca_MM
>
> which is a subset of a much larger list of items,
> is there an efficient algorithm to create condensed forms that match
> tho
This is a first try, is something like this enough for you?
data = """apple1
apple2
apple3_SD
formA
formB
formC
kla_MM
kla_MB
kca_MM""".split()
headtails = {}
for word in data:
head = word[:-1]
if head in headtails:
headtails[head].append(word[-1])
else:
headtails[hea
Here's the problem: Given a list of item names like:
apple1
apple2
apple3_SD
formA
formB
formC
kla_MM
kla_MB
kca_MM
which is a subset of a much larger list of items,
is there an efficient algorithm to create condensed forms that match
those items, and only those items? Such as:
apple[12]
apple3