-
-
Notifications
You must be signed in to change notification settings - Fork 553
isbn-verifier: Include more succinct description of ISBN-10. #1019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -1,4 +1,7 @@ | |||
Check if a given ISBN-10 is valid. | |||
Given a number, check if a given ISBN-10 is valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this line's change is an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the whole line can probably be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, I was just trying to mirror the Luhn description, as I find it a really good example for this kind of problem.
|
||
## Example | ||
|
||
Let's take a random ISBN-10 number, for instance `3-598-21508-8`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really a random ISBN-10 number.
This line is unnecessarily verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, that's why I slimmed it down. Do you think it should be reduced even more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
"For the ISBN-10 3-598..."
Be careful using "ISBN Number" since it has the "ATM Machine" issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RAS Syndrome! Good point - I'll strip that too.
|
||
## Example | ||
|
||
Let's take a random ISBN-10 number, for instance `3-598-21508-8`. | ||
The first digit block indicates the group where the ISBN belongs. Groups can consist of shared languages, geographic regions or countries. The leading '3' signals this ISBN is from a german speaking country. | ||
The following number block is to identify the publisher. Since this is a three digit publisher number there is a 5 digit title number for this book. | ||
The last digit in the ISBN is the check digit which is used to detect read errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this stuff about countries and publishers doesn't belong in the example any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I agree but was not confident in stripping it out without another opinion. If you think this should be removed then I'll do that too! 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual details of each section aren't relevant to the problem so removing them completely is not a bad option.
Another option is moving them up into the "about ISBN" section if we want to do more than just refer people to Uncyclopedia.
Given a number, check if a given ISBN-10 is valid. | ||
|
||
The [ISBN-10 verification process](http://www.hahnlibrary.net/libraries/isbncalc.html) requires use of a simple formula, and is mostly used to validate book identification | ||
numbers. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd re-phrase this, to focus on what the purpose of ISBNs are before talking about formulas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll give the problem context first 👍
``` | ||
|
||
If the result is 0, then it is a valid ISBN-10, otherwise it is invalid. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good description 👍
|
||
Which proves that the ISBN is valid. | ||
Since the result is 0, this proves that our ISBN is valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good clarification 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be one =
or two at the end of the line? Line 18 only has one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment re: line 9.
Check if a given ISBN-10 is valid. | ||
Given a number, check if a given ISBN-10 is valid. | ||
|
||
The [ISBN-10 verification process](http://www.hahnlibrary.net/libraries/isbncalc.html) requires use of a simple formula, and is mostly used to validate book identification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to wikipedia and solve all your describe 'ISBN' problems: https://en.wikipedia.org/wiki/International_Standard_Book_Number
Converting from string to number can be tricky in certain languages. | ||
It's getting even trickier since the check-digit of an ISBN-10 can be 'X'. | ||
Converting from strings to numbers can be tricky in certain languages. | ||
Now, it's even trickier since the check digit of an ISBN-10 may be 'X' (representative of '10'). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
representing
reads more cleanly to me than representative of
here.
@@ -1,4 +1,5 @@ | |||
Check if a given ISBN-10 is valid. | |||
The [ISBN-10 verification process](http://www.hahnlibrary.net/libraries/isbncalc.html) is mostly used to validate book identification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove this link, and replace it with the wikipedia one. This link doesn't give much useful information about the number and the formula given there conflicts with the one specified here. (1-9) are reversed on that page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't notice that! On it.
@@ -1,4 +1,5 @@ | |||
Check if a given ISBN-10 is valid. | |||
The [ISBN-10 verification process](https://en.wikipedia.org/wiki/International_Standard_Book_Number) is mostly used to validate book identification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"mostly"?
What else is it used for?
@@ -9,27 +10,30 @@ The program should allow for ISBN-10 without the separating dashes to be verifie | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're here: Line 8 is grammatically odd.
Also this is the first indication that there could be dashes in the number.
Maybe add an example number to the first paragraph.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
@@ -1,4 +1,5 @@ | |||
Check if a given ISBN-10 is valid. | |||
The [ISBN-10 verification process](https://en.wikipedia.org/wiki/International_Standard_Book_Number) is used to validate book identification | |||
numbers. | |||
|
|||
## Functionality |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do any other description.md
s have a Functionality section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was odd too. I am not too sure what the original author means - can you think of a better title? 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about: Move the whole functionality section under the example and rename it to 'Task'?
|
||
## Caveats | ||
|
||
Converting from string to number can be tricky in certain languages. | ||
It's getting even trickier since the check-digit of an ISBN-10 can be 'X'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an example valid ISBN with X as a check digit (from the canonical-data.json)
No need to show the calculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall do!
@@ -30,7 +30,7 @@ Since the result is 0, this proves that our ISBN is valid. | |||
## Caveats | |||
|
|||
Converting from strings to numbers can be tricky in certain languages. | |||
Now, it's even trickier since the check digit of an ISBN-10 may be 'X' (representing '10'). | |||
Now, it's even trickier since the check digit of an ISBN-10 may be 'X' (representing '10'). For instance `3-598-21507-X` is a valid ISBN-10. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Given an unknown string the program should check if the provided string is a valid ISBN-10. | ||
Putting this into place requires some thinking about preprocessing/parsing of the string prior to calculating the check digit for the ISBN. | ||
|
||
The program should allow for ISBN-10 both with and without separating dashes to be verified. For example, `3-598-21508-8` and `3598215088`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The program should allow for ISBN-10 both with and without separating dashes to be verified.
For example,3-598-21508-8
and3598215088
.
@@ -1,35 +1,40 @@ | |||
Check if a given ISBN-10 is valid. | |||
The [ISBN-10 verification process](https://en.wikipedia.org/wiki/International_Standard_Book_Number) is used to validate book identification | |||
numbers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add:
"These normally contain dashes and look like: 3-598-21508-8
"
or
"These often contain dashes and can look like: 3-598-21508-8
"
or something :)
Looks good, I need to go do some other stuff now. |
|
||
Since the result is 0, this proves that our ISBN is valid. | ||
|
||
## Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Task?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops!
|
||
## Test | ||
|
||
Given an unknown string the program should check if the provided string is a valid ISBN-10. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given a string, check if it is a valid ISBN-10
Closing github window 😁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You all went gang busters over night on this, found my inbox quite "full" 😄
I have some reading to catch up on. Quick glance thus far looks good!
|
||
Which proves that the ISBN is valid. | ||
Since the result is 0, this proves that our ISBN is valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be one =
or two at the end of the line? Line 18 only has one.
|
||
Which proves that the ISBN is valid. | ||
Since the result is 0, this proves that our ISBN is valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment re: line 9.
Hmm, that is a good point. Obviously this wants to be as language agnostic as possible - do you think '==' or '=' is better? |
I'd prefer `==`.
…On Tue, Nov 21, 2017 at 2:56 PM, Sam Warner ***@***.***> wrote:
Hmm, that is a good point. Obviously this wants to be as language agnostic
as possible - do you think '==' or '=' is better?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1019 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHdeTjC-HyStPP6yAc2jm81dvLlKBsaaks5s4taVgaJpZM4QlsBo>
.
|
I'm inclined to agree with @coriolinus |
A valid ISBN-10 is calculated with this formula `(x1 * 10 + x2 * 9 + x3 * 8 + x4 * 7 + x5 * 6 + x6 * 5 + x7 * 4 + x8 * 3 + x9 * 2 + x10 * 1) mod 11 == 0` | ||
So for our example ISBN this means: | ||
(3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 = 0 | ||
The program should allow for ISBN-10 both with and without separating dashes to be verified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would rephrase this slightly to emphasize that both are correct (the current wording only implies allowing them to be verified). Maybe something like:
The program should be able to verify ISBN-10 both with and without separating dashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still good 👍
Thanks for making this a better exercise @sjwarner-bp! |
Fixes exercism/problem-specifications#1011. A simple definition of what the system should do before getting in to exactly what the digits of an ISBN mean would be good, in my opinion. exercism/problem-specifications#1019
Fixes #1011 .