tablespace

master
remy 2020-04-25 14:15:47 +02:00
parent 43de6c1949
commit 9a5f918d76
1 changed files with 12 additions and 14 deletions

View File

@ -27,17 +27,16 @@ def is_valid_isbn(isbn_code)
pp "check_digit_isbn10" pp "check_digit_isbn10"
i = check = 0 i = check = 0
t = 10 t = 10
while i < 9 while i < 9
check = array[i].to_i * (t - i) + check check = array[i].to_i * (t - i) + check
i = i + 1 i = i + 1
end end
pp result = ( 11 - (check % 11)) % 11 pp result = ( 11 - (check % 11)) % 11
if (result - array[9].to_i) == 0 if (result - array[9].to_i) == 0
pp "isbn10 is ok" pp "isbn10 is ok"
else else
pp "isbn10 check key fail" pp "isbn10 check key fail"
end end
elsif isbn_code.size ==13 elsif isbn_code.size ==13
pp "isbn13" pp "isbn13"
pp "check_digit_isbn13" pp "check_digit_isbn13"
@ -52,10 +51,10 @@ def is_valid_isbn(isbn_code)
end end
pp result = 10 - (check % 10) pp result = 10 - (check % 10)
if result - array[12].to_i == 0 if result - array[12].to_i == 0
pp "isbn13 is ok" pp "isbn13 is ok"
else else
pp "isbn13 check key fail" pp "isbn13 check key fail"
end end
else else
pp "wrong size" pp "wrong size"
return false return false
@ -64,7 +63,6 @@ def is_valid_isbn(isbn_code)
pp "ko not only number" pp "ko not only number"
return false return false
end end
end end