P
Pilcrow
This problem was raised in comp.lang.perl.misc, and the poster was
concerned, among other things, by the speed of execution.
Since C is faster than perl, I wonder how a C coder would solve it?
Given a *very* long string, A, and a shorter string, B, extract all
substrings of A that differ from B in at most N positions.
For example:
N = 2
A = 'abcdefaacdefxbcxfaaabcdefaaaacdxf'
B = 'abcdef'
the substrings are 'abcdef' at offsets 0 & 19, 'aacdef' at offset 6, and
'aacdxf' at offset 27.
concerned, among other things, by the speed of execution.
Since C is faster than perl, I wonder how a C coder would solve it?
Given a *very* long string, A, and a shorter string, B, extract all
substrings of A that differ from B in at most N positions.
For example:
N = 2
A = 'abcdefaacdefxbcxfaaabcdefaaaacdxf'
B = 'abcdef'
the substrings are 'abcdef' at offsets 0 & 19, 'aacdef' at offset 6, and
'aacdxf' at offset 27.