Advertisement

01.02.2005 at 07:10AM PST, ID: 21259175
[x]
Attachment Details

string comparison, (a job for ozo?)

Asked by holli in Perl Programming Language

Tags: comparison, string, both, keep

     Given two strings of equal length that contain digits and some placeholder value, I want a fast way to determine if the pair are 'compatible'.

      Eg. Given (where underscore represents the placeholder but this could be substituted by any other non-digit value that helped the algorithm)

      _8__3__19
      48____7__

      These two strings are compatible because no single digit appears in both strings accept where it appears in the same position (8)

      Whereas these two would be incompatible

      _8__3__19
      4_8___7__

      because the digit 8 appears in both, but at a different position. And these two are incompatible

      _8__3__19
      48_____7_

      because the second last digit in both strings contains a different value.

      I know how to do this with a loop and substr and a hash, but it is rather slow and I have a set N of M sets of these strings and I want to produce a set P, where each element of P is a string that is combines one string from as many of the N sets of strings as are compatible. Given the combinatorial nature of the problem, I need to make it as quick as possible.

      I keep thinking that this can be done using string-wise boolean operations, but I cannot see how?

      If there is a better way of structuring the data (eg. arrays of char rather than strings) that makes the process quicker or easier that's good to.
      Examine what is said, not who speaks.
      Silence betokens consent.
      Love the truth but pardon error.

holli

Start Free Trial
 
Loading Advertisement...
 
[+][-]01.02.2005 at 09:26AM PST, ID: 12939671

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.02.2005 at 09:30AM PST, ID: 12939683

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.02.2005 at 09:45AM PST, ID: 12939732

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.02.2005 at 11:29AM PST, ID: 12940035

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.02.2005 at 11:34AM PST, ID: 12940054

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: comparison, string, both, keep
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 3
Solution Grade: A
 
 
[+][-]01.02.2005 at 12:01PM PST, ID: 12940127

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.04.2005 at 01:54AM PST, ID: 12950829

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.04.2005 at 02:00AM PST, ID: 12950854

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.04.2005 at 04:31AM PST, ID: 12951504

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.04.2005 at 04:32AM PST, ID: 12951508

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32