I am wondering if there is a fancy way to find the index of, the first character in string a that does not match the character in the same position of string b, aside from using brute force.
Here is the brute force attempt:
bool OnlyDiffersByCarotsAndSpaces(string a, string b)
{
if( a.Count() != b.Count() )
{
return false;
}
for(int index = 0; index < a.Count(); ++index)
{
if( a[index] != b[index] )
{
string validCharacters = " ^";
if( !validCharacters.Contains(a[index]) ||
!validCharacters.Contains(b[index]) )
{
return false;
}
}
}
return true;
}