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.139 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.138 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.137 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.136 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.135 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.134 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.133 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.132 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.131 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.130 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.129 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.128 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.127 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.126 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.125 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.124 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.123 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.122 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.121 tracks/lua/exercises/isbn-verifier/example.lua
trackler-2.2.1.120 tracks/lua/exercises/isbn-verifier/example.lua