6 kyu
Convert ISBN-10 to ISBN-13
520 of 1,117dienesviktor
Loading description...
Algorithms
Regular Expressions
Fundamentals
Strings
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.
I like to solve such tasks, I spent about 2 hours on the last ISBN10 calculation task, I won’t say that my calculation is optimal, but I always try to write my code more understandable for everyone, even if it eats a little more memory, but the experience is adaptation and optimization comes with age.
Nice kata : ) , if you want another isbn related kata then check this : https://www.codewars.com/kata/isbn-10-validation/javascript
why are the test output ISBNs in different formats - with dashes at different places? It doesn't mention this in the output instructions.
The description gives an exact algorithm to calculate the output from the input, what's the problem, concretely?
In the test, sometimes the expected isbn is in this format 000-0-00000-000-0 and sometimes it is in this format: 000-0-00-000000-0 and sometimes in this format: 000-000-00-0000-0
all of my isbns are returned in the first format so I'm failing th tests. HOw do I know which format to use for which ISBNs?
Oh I think I answered the question, because the dashes need to be in the same place as they are in the original? I was confused because I thought that ISBNs are always in the format of the first example in the tests above. I will have another go.
Yes, you need to reuse the input conserving its format.
COBOL translation.
It looks good to me. Thank you! :)
This comment has been hidden.
Read this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll#browser_compatibility and this: https://docs.codewars.com/training/troubleshooting#post-discourse
Thanks for your quick response
I consider, that the multiplication condition is incorrectly stated in point 4 ('1 or 3' Why?). check_digit = 9*1 + 7*3 + 8*1 + 1*3 + 8*1 + 5*3 + 3*1 + 2*3 + 6*1 + 1*3 + 5*1 + 8*3
Hi,
The first number is multiplied by 1, the second number is multiplied by 3, the third by 1, etc. There are 1 and 3, not "or". Maybe there’s something I’m not considering.
mmh, right. I was too much focused on the example.
edit: oh, actually, you're missing the "alternately" at the beginning of the sentence. So it seems actually correct.
Ruby translation kumited -- please check and approve! Köszi
It looks good to me. Köszi! :)
C translation 📚
It looks good to me. Thank you! :)
thanks !
Actually, all you do is prefixing
978
, then recalculating the check-digit. That could be phrased a bit more positively.Thank you for your suggestion! I reworded the description based on your advice.
The description describes about
Take 10 digits of ISBN then remove the last digit
which can make solvers think it is intended to select all digits in ISBN and remove the last one.This is not the case for inputs ending with
X
like0-02-346450-X
.So, it should be specified that the last suffix part (
-(X|\d)
) should not be considered in the calculation ~~( Remember to approve Haskell translation below before changing description to avoid merge conflict )
Thank you for the comment. I reworded the description based on your advice. Hopefully this will avoid misunderstandings. This will definitely help for the future solvers.
Looks good !
Haskell translation
( This translation updates the description for markup. )
It looks good to me. Thank you! :)
The JavaScript and Prolog versions generate strings in a different format compared to the Python version. Is this okay?
It seems there isn't one specific format in terms of groups' lengths that all ISBNs have to follow, so this is probably irrelevant.
It's about as messy as multi-byte Unicode ( or slightly worse ). See Wiki: List of ISBN registration groups.
It's not worth it to follow that format, that'd be a kata in itself ( and it would be a drag ).
( JS, possibly others )
JS identifiers by convention use camelCase ( unless they're
Constructor
s ). Please follow this convention.Yes, it's OK to invalidate existing solutions while in Beta.
Thank you for your comment! I fixed this issue in the JS translation.
.. by which ..
Thank you for your suggestion! Fixed.
Prolog translation available.
Edit: improved random ISBN generator fork: here.
It looks good to me. Thank you! :)
JS translation
Thank you! :)
This translation should have been reviewed more carefully before approval. It being OP's first translation could have been an indication. We all have to learn.
Thank you for your comment. Sorry, I didn't know I had to check the translations. I'll check it and fix the reported issues soon.
We all have to learn. :D ( and it never stops :P )
Sorry, I assumed that function names were to be directly copied when translating. I'll keep that in mind for the future.
Hi,
This has to be explained in the description too.
Cheers
Hi! Thank you for your comment. I added an explanation to the description. This will definitely help for the solvers.
:+1:
Sample tests are not using
describe
blocks. Solution and test framework are not imported there either.Thank you for your comment. I fixed the indicated error. This is my first KATA, so this is good advice for me.