You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/BuildReport/Scripts/Editor/FuzzyString/HammingDistance.cs

29 lines
493 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FuzzyString
{
public static partial class ComparisonMetrics
{
public static int HammingDistance(this string source, string target)
{
int distance = 0;
if (source.Length == target.Length)
{
for (int i = 0; i < source.Length; i++)
{
if (!source[i].Equals(target[i]))
{
distance++;
}
}
return distance;
}
else { return 99999; }
}
}
}