Skip to content
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

Hamming distance definition differs in Python and Ruby #1867

Closed
typograph opened this issue Sep 25, 2014 · 2 comments
Closed

Hamming distance definition differs in Python and Ruby #1867

typograph opened this issue Sep 25, 2014 · 2 comments

Comments

@typograph
Copy link

In Python the test suite seems either to be counting 'missing' characters, or to compare from the end of the string (strangely, this gives the same result in the provided cases).

    def test_hamming_different_length1(self):
        self.assertEqual(4, hamming('AAGCTAC','ACGTT'))
    def test_hamming_different_length2(self):
        self.assertEqual(5, hamming('AAGCTAC','ACGTTACGTC'))

In Ruby the test suite says to ignore the extra characters

    def test_ignores_extra_length_on_first_strand_when_longer
        assert_equal 1, Hamming.compute('AGAGACTTA', 'AAA')
    end
    def test_ignores_extra_length_on_other_strand_when_longer
        assert_equal 2, Hamming.compute('AGG', 'AAAACTGACCCACCCCAGG')
    end

And Wikipedia says the Hamming distance is not defined for strings of different length.

I am not saying the problems cannot be different, but for such a well-defined concept it would make sense to stick to one definition, especially when the READMEs provide so little information about what is expected from the implementation.

@kytrinyx
Copy link
Member

I opened an issue in each of the language tracks that have either Hamming or the older Point Mutations exercise, that is also based on the Hamming distance. I'm going to close this issue and let each language track handle this separately. There's an open pull request in the Python track.

Thanks so much for bringing this up, it's definitely an improvement.

@kytrinyx
Copy link
Member

FYI - very interesting discussion about this problem here: #1910

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

No branches or pull requests

2 participants