7 kyu
ISBN Corruption
170alexlostorto
Loading description...
Strings
Algorithms
Arrays
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Haskell translation
The kata doesn't rule out the possibility where
?
appears before the last digit, and the only digit that can satisfy the checksum isX
, which can only appear in the last digit.Either this needs to be explicitly ruled out, or it needs to be tested.
Hi! There's a generateCode() function which will generate a valid ISBN code. That function can only ever return
X
as the last digit, so I don't believe it's something that would happen in the tests.Also, in the description, it mentions that only the last digit can be X
Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit as X. For example, 156881111X.
Maybe I'm misunderstanding your issue??
What is the expected result for input
?11111111X
then?This comment has been hidden.
Yes, I'm aware of that, in this case you need to explicitly rule this out in the description (aka state that the answer will always be valid).
Ahh ok thanks for your patience in resolving this :)
I've altered the description to make this more explicit:
Write a program that reads in an ISBN code (will always be valid)...
Returning different typed values is a bad practice (it doesn't fly in strongly-typed languages), and it's entirely a design problem: if we're supposed to return a digit, we should definitely return the digit as a character/string, not only when it is
X
. This would make it consistent and avoid the potential problem mentioned above.Just standardised the return type as a string.
Thanks for the explanation too! :)