Skip to content

Update isbn-verifier.spec.js#734

Merged
tejasbubane merged 1 commit intoexercism:masterfrom
pyko:patch-1
Oct 3, 2019
Merged

Update isbn-verifier.spec.js#734
tejasbubane merged 1 commit intoexercism:masterfrom
pyko:patch-1

Conversation

@pyko
Copy link
Copy Markdown
Contributor

@pyko pyko commented Oct 2, 2019

Updating X is only valid as a check digit test so if X in the middle of ISBN is treated as 10 the test will fail.

Changing check digit to 9 means checksum('3-598-2X507-9') mod 11 == 0, so solutions which simply replace X with 10 (without checking location) will treat 3-598-2X507-9 as a valid ISBN.

Updating 'X is only valid as a check digit' test so if `X` in the middle of ISBN is treated as `10` the test will fail.

Changing check digit to `9` means `checksum('3-598-2X507-9') mod 11 == 0`, so solutions which simply replace `X` with `10` (without checking location) will treat `3-598-2X507-9` as a valid ISBN.
@SleeplessByte
Copy link
Copy Markdown
Member

@petertseng just tagging you because I want to be certain this can actually be applied and applied everywhere. In that case its a bugfix and we can lift it to problem-spec.

@petertseng
Copy link
Copy Markdown
Member

This PR is the correct thing to do; an implementation that treats X as 10 in all positions would still reject 3-598-2X507-0, therefore 3-598-2X507-0 is not a good test case. Such an implementation would declare 3-598-2X507-9 a valid ISBN, so 3-598-2X507-9 is the correct test case. Please see exercism/problem-specifications#993.

@petertseng
Copy link
Copy Markdown
Member

Please see the following:

0 * 1 (0)
7 * 2 (14)
0 * 3 (0)
5 * 4 (20)
X * 5 (50)
2 * 6 (12)
8 * 7 (56)
9 * 8 (72)
5 * 9 (45)
3 * 10 (30)
total: 299 (divisible by 11? false)\

9 * 1 (9)
7 * 2 (14)
0 * 3 (0)
5 * 4 (20)
X * 5 (50)
2 * 6 (12)
8 * 7 (56)
9 * 8 (72)
5 * 9 (45)
3 * 10 (30)
total: 308 (divisible by 11? true)

@SleeplessByte
Copy link
Copy Markdown
Member

Sweet. Thank you for that elaboration @petertseng ❤️

Copy link
Copy Markdown
Member

@tejasbubane tejasbubane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@tejasbubane tejasbubane merged commit b258063 into exercism:master Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants