Skip to content

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

Merged
merged 12 commits into from
Nov 22, 2017

Conversation

sjwarner-bp
Copy link
Contributor

Fixes #1011 .

@@ -1,4 +1,7 @@
Check if a given ISBN-10 is valid.
Given a number, check if a given ISBN-10 is valid.
Copy link
Contributor

@Insti Insti Nov 21, 2017

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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`.
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

@Insti Insti Nov 21, 2017

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.

Copy link
Contributor Author

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! 🙂

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Good clarification 👍

Copy link
Member

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.

Copy link
Member

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
Copy link
Contributor

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').
Copy link
Member

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
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

@Insti Insti Nov 21, 2017

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

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Do any other description.mds have a Functionality section?

Copy link
Contributor Author

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? 🙂

Copy link
Contributor

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'.
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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`.

Copy link
Contributor

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 and 3598215088.

@@ -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.
Copy link
Contributor

@Insti Insti Nov 21, 2017

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 :)

@Insti
Copy link
Contributor

Insti commented Nov 21, 2017

Looks good, I need to go do some other stuff now.
I'll leave it a while and see what others have to suggest.
Thanks for all your work on this.


Since the result is 0, this proves that our ISBN is valid.

## Test
Copy link
Contributor

Choose a reason for hiding this comment

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

Task?

Copy link
Contributor Author

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.
Copy link
Contributor

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

@Insti
Copy link
Contributor

Insti commented Nov 21, 2017

Closing github window 😁

@rpottsoh rpottsoh changed the title Update description.md with more succinct description of ISBN-10. isbn-verifier: Include more succinct description of ISBN-10. Nov 21, 2017
Copy link
Member

@rpottsoh rpottsoh left a 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.
Copy link
Member

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.
Copy link
Member

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.

@sjwarner-bp
Copy link
Contributor Author

Hmm, that is a good point. Obviously this wants to be as language agnostic as possible - do you think '==' or '=' is better?

@coriolinus
Copy link
Member

coriolinus commented Nov 21, 2017 via email

@sjwarner-bp
Copy link
Contributor Author

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.
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! 👍

Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

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

Great work!

Copy link
Contributor

@Insti Insti left a comment

Choose a reason for hiding this comment

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

Still good 👍

@rpottsoh
Copy link
Member

Thanks for making this a better exercise @sjwarner-bp!

@rpottsoh rpottsoh merged commit 2d97a9b into exercism:master Nov 22, 2017
petertseng added a commit to exercism/rust that referenced this pull request Dec 18, 2017
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
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.

6 participants