-
-
Notifications
You must be signed in to change notification settings - Fork 555
Description
This might be more detail than is needed, but it's something I noticed when completing the exercise.
The approached the problem by iterating over the first ten digits of the input and applying the algorithm in the description; any trailing digits were ignored. This passed all the test cases in the example. However, the test cases for ISBNs that were too long failed because the digits that they did happen to test were not a valid ISBN, and it was pretty easy to craft a string that was too long (and therefore not an ISBN) but passed the validator.
So, the proposal:
For exercises validating ISBN length ("too long isbn" and "too long isbn no dashes"), the first ten digits of the input should be a valid ISBN in order to catch solutions that ignore trailing digits.
As an extra twist, to catch folks approaching the problem by iterating in reverse, the test input could be eleven digits, the first ten and last ten of which are valid ISBNs (e.g: 35982150886
).