Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
16
Task/ISBN13-check-digit/MiniScript/isbn13-check-digit.mini
Normal file
16
Task/ISBN13-check-digit/MiniScript/isbn13-check-digit.mini
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
isISBN13 = function(n)
|
||||
n = n.replace("-","").replace(" ","")
|
||||
s = 0
|
||||
for i in range(0, n.len-1,2)
|
||||
s += n[i].val
|
||||
end for
|
||||
for i in range(1, n.len-1,2)
|
||||
s += n[i].val * 3
|
||||
end for
|
||||
return not (s % 10)
|
||||
end function
|
||||
|
||||
testValues = "978-0596528126 978-0596528120 978-1788399081 978-1788399083".split(" ")
|
||||
for val in testValues
|
||||
print val + " " + ["bad", "good"][isISBN13(val)]
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue