Assuming this is homework, and further to AnonyMonk's comment "This logic is akin to NXOR ie equality" above, consider the stringwise xor of two strings of equal length in which some characters at corresponding positions are the same and some are not.

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $m = ' 0 1 0 1'; my $p = ' 0 0 1 1'; ;; my $x = $m ^ $p; dd $x; " "\0\0\0\1\0\1\0\0"
A  "\0" character (\000 octal, 0x00 hex) is produced in the resultant string at each position where the characters in the two input strings are the same. (Note that there are three different characters in the example input strings: space, '0' and '1'.) Something other than a  "\0" character is produced everywhere else.

The resultant string can then be analyzed by a regex to pick out sequences of  "\0" characters that indicate regions of equality between the two input strings. This is the "traditional" way to quickly compare two strings of the same length for position-by-position | for regions of position-to-position equality/inequality. I would build my solution on this string-xor property: look for pairs of strings in which the ' 0 1 0 0 1 1' regions at the ends of each string are the same.

Like u65, I have a solution that I am reluctant to post because of the homeworkish odor of the OP. Please show some more work, or convincing evidence that you are totally stuck for a way forward.

Update: Clarification to this reply made in response to private query by GotToBTru.


Give a man a fish:  <%-{-{-{-<


In reply to Re: SEEKING HELP by AnomalousMonk
in thread SEEKING HELP by A1 Transcendence

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.