Synced ISBN-Verifier to Problem Specifications

Updated exercise instructions
Accepted new additional test case
Regenerated test file and verified example solution continues to pass.
This commit is contained in:
BethanyG
2022-05-05 19:07:22 -07:00
parent b1668d5884
commit 41bd7c47ec
3 changed files with 7 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ numbers. These normally contain dashes and look like: `3-598-21508-8`
The ISBN-10 format is 9 digits (0 to 9) plus one check character (either a digit or an X only). In the case the check character is an X, this represents the value '10'. These may be communicated with or without hyphens, and can be checked for their validity by the following formula: The ISBN-10 format is 9 digits (0 to 9) plus one check character (either a digit or an X only). In the case the check character is an X, this represents the value '10'. These may be communicated with or without hyphens, and can be checked for their validity by the following formula:
```text ```text
(x1 * 10 + x2 * 9 + x3 * 8 + x4 * 7 + x5 * 6 + x6 * 5 + x7 * 4 + x8 * 3 + x9 * 2 + x10 * 1) mod 11 == 0 (d₁ * 10 + d₂ * 9 + d₃ * 8 + d₄ * 7 + d₅ * 6 + d₆ * 5 + d₇ * 4 + d₈ * 3 + d₉ * 2 + d₁₀ * 1) mod 11 == 0
``` ```
If the result is 0, then it is a valid ISBN-10, otherwise it is invalid. If the result is 0, then it is a valid ISBN-10, otherwise it is invalid.

View File

@@ -21,6 +21,9 @@ description = "valid isbn with a check digit of 10"
[3ed50db1-8982-4423-a993-93174a20825c] [3ed50db1-8982-4423-a993-93174a20825c]
description = "check digit is a character other than X" description = "check digit is a character other than X"
[9416f4a5-fe01-4b61-a07b-eb75892ef562]
description = "invalid check digit in isbn is not treated as zero"
[c19ba0c4-014f-4dc3-a63f-ff9aefc9b5ec] [c19ba0c4-014f-4dc3-a63f-ff9aefc9b5ec]
description = "invalid character in isbn is not treated as zero" description = "invalid character in isbn is not treated as zero"

View File

@@ -20,6 +20,9 @@ class IsbnVerifierTest(unittest.TestCase):
def test_check_digit_is_a_character_other_than_x(self): def test_check_digit_is_a_character_other_than_x(self):
self.assertIs(is_valid("3-598-21507-A"), False) self.assertIs(is_valid("3-598-21507-A"), False)
def test_invalid_check_digit_in_isbn_is_not_treated_as_zero(self):
self.assertIs(is_valid("4-598-21507-B"), False)
def test_invalid_character_in_isbn_is_not_treated_as_zero(self): def test_invalid_character_in_isbn_is_not_treated_as_zero(self):
self.assertIs(is_valid("3-598-P1581-X"), False) self.assertIs(is_valid("3-598-P1581-X"), False)