For example, I am given the following string of 0's and 1's : 001011. This is my pattern, or string A. Then, I am given a longer string B of 0's and 1's (example: 010100010010010) and my task is to find the the most appropriate match of string A in B, and I say ,,the most appropriate" because it doesn't need to be necessarily string A, it could have an error of maximum 20%.
For example: for string A: 01001, a good match would be 11001. 80% percent of string B matches string A, except the first bit. For the same A string, 11101 would match only 60% of it (the bits on the first and third position in 11101 do not match the first and the third bit in A) which is not the desire solution.
If N is the number of bits of string A, it means that I perform a check on an N-length sequence of B at once (the evaluated bits in B must be on consecutive positions, so this excludes a substring from B). For example: Let it be A- 01011 and B-010100100111. First we evaluate the sequence 01010 (the first 5 bits of B starting with the very first position), then 10100 (the first 5 bits starting with the second bit in B). In this example, in 01010 only 4 bits match with A, that means 01010 is a 80% match. Concerning 10100, no bit match with A, thus it is a 0% match.
I could have a case where A is: 01001 and B is: 01101 ( the first 2 bits from B match the first 2 bits of A and the last 2 bits of B match the last 2 bits A). Therefore, it is a 80% match.
If A is longer than B, then A has no match in B.
I would like to know an algorithm, strategy to attack this problem. I hope I made this problem as clear as possible, if not, I am going to modify of provide you with further explanations. I assume this problem might actually have some applications in real world in regard to pattern-matching. I need a solution and I am looking forward to improving the explanations as much as possible.