Sha256: 59ca9b92b8f5611410c97c626d371e555d912eec1af218e8e7853f24b9476f1d

Contents?: true

Size: 218 Bytes

Versions: 97

Compression:

Stored size: 218 Bytes

Contents

local Hamming = {}

function Hamming.compute(a,b)
  local distance = 0
  for i = 1, a:len() do
    if (a:sub(i, i) ~= b:sub(i, i)) then
      distance = distance + 1
    end
  end
  return distance
end

return Hamming

Version data entries

97 entries across 97 versions & 1 rubygems

Version Path
trackler-2.0.6.41 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.40 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.39 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.38 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.37 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.36 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.35 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.34 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.33 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.32 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.31 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.30 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.29 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.28 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.27 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.26 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.25 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.24 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.23 tracks/lua/exercises/hamming/example.lua
trackler-2.0.6.22 tracks/lua/exercises/hamming/example.lua