[Community Puzzle] ISBN Check digit

I just wanna say that
“In case 10 being the value needed to add to the sum, we use X as the check digit instead of 10”
did not help me to understand what the requirement was actually asking me to do. Also, i was under the impression the x was case-sensitive. If possible, please fix some of the wording to allure to this in a more easily understood phrasing, or perhaps standardize the test cases.
Thanks.

An extra test case in the Example and a little more wordings were added to the statement - to further clarify the ISBN structure.

2 Likes

Hi everybody,
New for a few months, I tried it this morning.
All test cases are ok but not validator…
I think I checked all the helps given here, but it is still not working : validator 3 is not ok.
Could some one help me please ?
Thanks

Try this as a Custom Test Case:

21
9781118336922
0880221577
0070667608
9781305109919
9781305273764
201183991
0023609516
9783319175744
9783319515168
8131760529
812X335961
0672301997
ignore_meX
0830645918
0140088911
9780471142737
080442957X
097522980X
9781482587630
9781406891065
1544777434

Expected output:

3 invalid:
201183991
812X335961
ignore_meX
3 Likes

Thanks Yatech !
It helps !
It would be really interesting to make it the fifth test !

Thank you for this Test Case, my code works now. Before, it crashed here - ignore_meX. I have fixed it in ISBN-13 too. But when I submit my code it fails at Validator 2(Short) and I don’t know why. Can everyone help me?

If your program passes these several rules, it should be correct:

  • correct total length
  • 0…9 for all digits at the front
  • for isbn10, 0…9|X for the last digit
  • for isbn13, 0…9 for the last digit
  • correct calculated result in the check-digit
1 Like

Еverything seems to be fine with my program… What is the test case at Validator 2?

I just finished a bash example for this.

I found that Validator #3 has a case that is not covered in any of the test cases. I can’t help more than that because there is no output on the validators.

My Submissions 1-3 all pass every test case and every validator except for validator #3.
Submission 4 gets 100%

same here
validator 3: Longer Validator
fails.
idk why

Have you tried the custom cases here?

My code:

def check_10_digit(isbn):
    _sum = 0
    for i in range(9):
        weight = 10-i
        _sum += int(isbn[i])*weight
    if isbn[9] == "X":
        _sum += 10
    else:
        _sum += int(isbn[9])
    if _sum % 11 == 0:
        return True
    else: return False

fails here:

ValueError: invalid literal for int() with base 10: ‘X’

at Answer.py. in check_10_digit on line 42

at Answer.py. in check on line 28

at Answer.py. in on line 69

The error means you’re trying to convert “X” to an integer. You have to check whether a character is a digit before conversion and, more importantly, whether “X” should appear in a particular position or not.