6 kyu
Hamming Distance
2,425 of 7,547eridgd
Loading description...
Algorithms
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.
In ruby, returning any integer will cause the test cases to pass. Was confused why I was passing the fixed ones but not the random ones and I just had some logic backwards and I should have been failing all of the fixed ones too.
fixed, thanks for your report
It is too easy to be 6 Kyu.
sadly, ranks cannot be changed.
yeah yeah, I understand. It's ok. I just shared my thoughts.
Lua translation!
For Python at least it's too easy for 6 kyu and too hard for 8 kyu. I think it should probably be 7kyu.
unfortunately, ranks are shared across languages and cannot be changed.
This comment has been hidden.
added fixed tests for the empty string and 1-character strings, and modified the RNG so that shorter strings can be generated.
Scala translation
Approved.
When I looked at the name of this kata, I thought that I would have to calculate the difference between bit arrays, not whole characters.
I would love to solve 1000 more 6kyus like this one.
8 kyu... realy
I resolved it and the test doesnt work properly. Actually I use all the examples that shows the Test case below and all succeded...
Your code is wrong, not a kata issue.
3 differences there, your function returns 6.
More appropriate for 8 kyu
Groovy translation kumited. Please review and approve. Thanks, suic
I rejected this version, but feel free to fork, fix, and republish.
See comments on the translation for hints.
Here's the new one. The random input generation is not as sofisticated as in the new random tests in Python but I guess it's sufficient.
Looks cool
Clojure translation has no random tests.
For js its to simple for 6 kyu
Hello everyone, I am new here but happy to be here. I am confused with the question, It is actually the my first try. I need help?
You can ask for help on the Discord "beginners" channel.
It's not clear if input contains only ASCII characters.
Is this important for any reason? Would tests or solutions be different if inputs are all-ASCII or not?
I believe so, if you iterate strings each "char" at a time. Many unicode characters require more than one "char" instance.
Comparing bytes is incorrect if there can be multibyte characters, but iterating bytes (or even code units instead of code points) is more efficient or just easier in languages where strings aren't just arrays of codepoints (which they are not in C-based, JS-based, Java-based and many other languages).
Ah OK, I get it now. As usual, I misread/misunderstood the initial issue.
The inputs were ASCII from the beginning, I did not change this part when reviewing the languages. Do you think such note would be sufficient?
Yes.
I added a note on ASCII inputs, now i'd have to check what languages do not conform.
This comment has been hidden.
This is not only a C++ kata. Maybe there should not have been a C++ translation if it's so simple in the language.
Or just enjoy the cheap points. :]
Or if you don't want the points, return them to sender.
PHP translation.
Updated Rust translation, with uptated language version and resolved merge conflicts.
approved
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/129.
Please join the discussion to help us identify duplicate kata and retire them.
This kata was decided to stay.
Please, C++ Translation
Approved.
Why did you change my solution?(
Because translation is not a good place to flex skills of obscure coding techniques. it needs to be maintainable and possible to support by others.
Why is this a problem tho? You can submit your solution now separately, cannot you?
This is a place for developing, right? Why not let others to develop their skills and get new knowledge? It must have for 1kyus or dans! What for all these ranks then?
Yes, you are right, this is place for learning and developing. And this is why you can just submit your intrinsics solution, it will be visible as yours on the Solutions tab, it will get many
clever
votes, and others will see it and learn from it.uniapi, will you maintain the c++ translation till end of time? ... ofcourse not, that is exactly why maintainable code is expected for translations
dfhwze, it seems that you did not even follow the code! Because from
it's clear what should be deleted! But instead you just decide not to approve my translations not only this one! It's not a problem for me! Because i do hope that one day under the will of The ALMighty i will push all my approved and not approved translations to my cws github repo as long with a new assert operator!
And believe! It's not dozens! They are more than two hundreds! ;)
This is a duplicate of Hamming Distance - Part 1: Binary codes (7 kyu) I just kopied and pasted my code from the above mentioned and it worked.
I agree. Though some codes written for the 7 kyu may not pass this one.
I have posted the other one as a duplicate, because this one is older. I was not aware of the subtle difference noted by
akar-0
. Is it a valid issue nonetheless?NASM translation
approved
COBOL translation (author inactive).
approved
C translation (author gone)
thanks :)
No sample tests and random test in JS and CS
JS already has sample test (maybe someone else added it).
Added random test for JS
added to CoffeeScript
Very easy, it's like 8kyu
This comment has been hidden.
Tests on the javascript are broken (like you can just return 1)
Fixed.
I think this is rather a 7 kyu kata than a 6.
Or 8
Or 9
I've made a rust translation, please take a look!
Replaced with an updated version.
make test cases from the examples (JS version)
I've added a translation to C#. Contains random tests too. Please check and approve.
Oups. I somehow implemented Levenshtein instead of Hamming. Worked well on most tests, took me a while to figure out what my problem was :)
I have done this kata in multiple different ways, each of which work in other Python 2.7 IDEs, but no matter what I do, whenever I Run Tests or Submit I get the generic respose 'Submission timed out. Please try again.'
For Python, this kata should not link to the Wikipedia article, which includes Python code to demonstrate the algorithm, and should provide its own explanation of what Hamming distance is.
Agree
I had to rename the tests namespace to Hamming-test to avoid a server side error about Hamming.clj file already existing. Other than that nice kata
Your test cases are bad. Very bad.
This comment has been hidden.
Language?
Non issue without more elements. Please give some arguments (and of course, language).
My initial solution ended up transposing a couple of parameters and I don't believe it should have passed. You should look into this.
Language?
Non issue without more elements. Please give a clear example of failed tests / bad code (+ obviously, language).
This comment has been hidden.
This comment has been hidden.
Missing test cases.