in reply to Re: Optimizing a string processing sub
in thread Optimizing a string processing sub
Unfortunately (unfortunate because it is clever and short) -- I believe your solution is flawed.
Using the words 'aabcc' and 'abbbc', your code suggests that the words have 5 characters in common. The original poster was vague about the requirements, however, I suspect that if both words have 5 characters, a declaration that the words have 5 characters in common, with different words, may be unexpected.
With this in mind, I suggest that your first example is correct if the goal is to determine the sum of the number of characters that is in each word that are also in the other word (probably not what the original posted wanted to see), and that the second does not do what you expect.
Good luck tweaking your solution... :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Optimizing a string processing sub
by sauoq (Abbot) on Jan 08, 2003 at 22:36 UTC | |
by MarkM (Curate) on Jan 08, 2003 at 23:15 UTC | |
by sauoq (Abbot) on Jan 08, 2003 at 23:54 UTC | |
|
Re: Re: Re: Optimizing a string processing sub
by spurperl (Priest) on Jan 09, 2003 at 05:53 UTC | |
by MarkM (Curate) on Jan 09, 2003 at 06:20 UTC | |
by sauoq (Abbot) on Jan 09, 2003 at 08:31 UTC | |
by dragonchild (Archbishop) on Jan 09, 2003 at 15:11 UTC |