Sha256: 0a42e51065292b3801c2acd3b8a785db00fdf7ab1bfd806de854499543068908

Contents?: true

Size: 292 Bytes

Versions: 107

Compression:

Stored size: 292 Bytes

Contents

return {
  valid = function(isbn)
    isbn = isbn:gsub('-', '')

    if not isbn:match('^%d%d%d%d%d%d%d%d%d[%dX]$') then
      return false
    end

    local sum = 0
    for i = 1, 10 do
      sum = sum + (11 - i) * (tonumber(isbn:sub(i, i)) or 10)
    end

    return sum % 11 == 0
  end
}

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.158 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.157 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.156 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.155 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.154 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.153 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.152 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.151 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.150 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.149 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.148 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.147 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.146 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.145 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.144 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.143 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.142 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.141 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.140 tracks/lua/exercises/isbn-verifier/example.lua