Sha256: 75dc98fc5422f68a41dc8fc4b2043f4ce397c0551c261a0d8913423698708a48

Contents?: true

Size: 251 Bytes

Versions: 299

Compression:

Stored size: 251 Bytes

Contents

local Hamming = {}

function Hamming.compute(a,b)
  if #a ~= #b then return -1 end
  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

299 entries across 299 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.138 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.137 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.136 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.135 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.134 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.133 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.132 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.131 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.130 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.129 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.128 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.127 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.126 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.125 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.124 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.123 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.122 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.121 tracks/lua/exercises/hamming/example.lua
trackler-2.2.1.120 tracks/lua/exercises/hamming/example.lua