[Community Puzzle] ISBN Check digit

Updated a few examples to catch certain exceptions.
BTW, “Convert digit 0-8 / 0-11 to an integer” is incorrect, at least a typo.

Perfect, thanks! That helped a lot to find the error in my code (uninitialized integer => 0, interpreted as correct checksum sigh)

No, i was just referring to the string indizes, so my count starts with 0 instead of 1.

so my count starts with 0 instead of 1
I see. Then try out the new samples, and look out for invalid format besides only checking the last char.

I completely rewrote my code. Now I pass all test cases but fail on the third validator. I think I just pass on this puzzle. It caused way too much anger.

msg me your code perhaps I could show you what’s wrong

fyi i got it working with your recent changes to validators. :+1:

:+1::+1: :computer:~~

Hi,

I have passed all the tests, but I cannot validate the example validation.
Do you have any hint about the test which could cause it ?

Thank you.

Hi, i have an issue I don’t understand with this game, in the last validator, I found that this is an error and the validator says it’s not :
9780134177296
but the sum == 112
112 % 10 = 2
10 - 2 = 8
6 != 8 so there is a mistake, I don’t understand why it does not pass

Hey @m1602,
9780134177296 is not in the validation tests set, it is in the last test case. And it is rendered invalid.
I’m confused a bit about what your issue is. Do you mean that the last validation test fails (upon submission)?

1 Like

Hi, thanks for the answer, I got this ISBN in “Much longer” test, I’m trying to validate all the editor test case before submitting
I’m writing it as invalid but the test seems to say it’s not

EDIT
Actually my mistake seems to be somewhere else, I think I found it, I must have misread something in the result cause I can’t reproduce my previous problem, sorry

Lo

I got the exact same problem in PHP. I output first the number of invalid isbn i found (with a newline) and then loop on the array of invalid isbns which i echoed with a newline.

If I suppress the newlines everything appears on one line and it’s wrong,I trim the isbn in the array to get sure there is nothing lurking around to no avail…

And now I ran out of ideas…Any hint?
Thx

When you got errors, it is more likely related to incorrect algorithm or calculation, or not fully implementing the isbn spec, or making invalid assumptions about the spec, than about newline characters.
Provide more details of your issue perhaps someone could point out what’s the problem.

I am having a had time as well. Basically I don’t understand where the error lies.

Some output of the second test:

### Standard Output Stream:
Input: ['0470371722', '9781119247792', '9780470124512', '11190495550', '1118105354', '9781118737637', '0387372350', '154875155X', '9781548751555', '978193981677']
ISBN: 0470371722
Calculated sum: 174
Calculated remainder 2
Checkdigit : 2
Found valid: 0470371722
ISBN: 9781119247792
Calculated sum: 119
Calculated remainder 1
Checkdigit : 2
Did not match (invalid): 9781119247792
ISBN: 9780470124512
Calculated sum: 88
Calculated remainder 2
Checkdigit : 2
Found valid: 9780470124512
ISBN: 11190495550
Did not match (invalid): 11190495550
ISBN: 1118105354
Calculated sum: 128
Calculated remainder 4
Checkdigit : 4
Found valid: 1118105354
ISBN: 9781118737637
Calculated sum: 113
Calculated remainder 7
Checkdigit : 7
Found valid: 9781118737637
ISBN: 0387372350
Calculated sum: 220
Calculated remainder 11
Checkdigit : 0
Did not match (invalid): 0387372350
ISBN: 154875155X
Did not match (invalid): 154875155X
ISBN: 9781548751555
Calculated sum: 115
Calculated remainder 5
Checkdigit : 5
Found valid: 9781548751555
ISBN: 978193981677
Did not match (invalid): 978193981677
5 invalid:
9781119247792
11190495550
0387372350
154875155X
978193981677
### Failure
Found: 
5 invalid:
Expected: 
4 invalid:

You got check digit of 0, why it was labelled as invalid?

Lo
First thanks for your answer and for the nice problem. I finally solved it. Where did the error lies in my code? Well, the dummy PHP code is, i think, a bit misleading (cc @TwoSteps) it’s written at the end:

// Write an action using echo(). DON'T FORGET THE TRAILING \n

So basically i echoed a sentence like this (without the whitespaces am adding for sake of clarity):

"X invalid:\n isbn1\n isbn2\n isbn3\n"

As soon as i trimmed this and removed the trailing \n I successfully submitted it…
Thx

next time , try :

echo implode("\n",$array);

it works and it’s opensource :smile:

1 Like

Oh yes, i discovered this func watching your code, am just beginning in php…thx for the tip :+1::+1::+1:

Ty. was able to find my issue, I did calculate the validity in some strange way. As stated in the desc you should do (sum + checkdigit)%10 or (sum + checkdigit)%11

All my test cases pass, once submit the code it fail on the third validator. I don’t have hard coded solutions, if not all the validators would fail. Can anyone help, please?