--!native --!optimize 2 -- Compiled with roblox-ts v3.0.0 local TS = _G[script] local CharAt = TS.import(script, script.Parent.Parent, "Utils", "CharAt") --[[ * * Calculates Hamming distance between two strings. * For unequal lengths, adds the difference in lengths to the mismatch count. ]] local function HammingDistanceScore(term, query) local min_len = math.min(#term, #query) local max_len = math.max(#term, #query) local distance = max_len - min_len do local i = 0 local _shouldIncrement = false while true do if _shouldIncrement then i += 1 else _shouldIncrement = true end if not (i < min_len) then break end if CharAt(term, i) ~= CharAt(query, i) then distance += 1 end end end return distance end return { HammingDistanceScore = HammingDistanceScore, }