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 to use wikipedia definition #44

Closed
wants to merge 1 commit into from
Closed

Hamming to use wikipedia definition #44

wants to merge 1 commit into from

Conversation

dalexj
Copy link
Contributor

@dalexj dalexj commented Nov 17, 2014

Issue #31

@kytrinyx
Copy link
Member

This change goes from defining the hamming distance of strings of unequal length to whatever the shortest overlap is (unlikely to be correct), to raising an error.

I would be fine with either raising an error, or simply removing the tests ("result is undefined for strings of unequal length").

@kotp the official definition is mathematical, and I haven't taken the time to dig into whether or not that definition includes some defined behavior for strings/bit vectors of unequal length.

@kotp
Copy link
Member

kotp commented Nov 22, 2014

I only mention it from your statement "Let's clean this up so that we're using the official definition." in Issue #31 which may or not be what you really want.

@kytrinyx
Copy link
Member

Yes, I understand. I was imprecise. I don't really want exercism to be particularly algorithmic -- there's already Euler Project for that.

@kytrinyx
Copy link
Member

Thinking about this some more, I would rather not raise errors in Hamming, since it is the first exercise on the ruby track of exercism. I'd rather leave it undefined (remove the tests), since then the discussion can talk about what happens when the inputs are of unequal length.

There are enough very new programmers on the Ruby track that introducing error handling in the first problem might be a bit of a high barrier to getting their first win.

@kytrinyx kytrinyx closed this in 3cbd1b5 Nov 24, 2014
@kytrinyx
Copy link
Member

Thank you, everyone, for taking the time to discuss this, and for bearing with my confusion and indecision. I've gone ahead and removed the offending tests in master.

@markijbema
Copy link
Contributor

(on a sidenote) Comparing vectors of different length makes no mathematical sense whatsoever, so I wouldn't think it's mathematically defined.

kytrinyx added a commit that referenced this pull request Mar 31, 2015
This removes the tests that define behavior for cases where the strings are of unequal
length. Since the hamming problem is the first one on the Ruby track, and so many people
who are new to programming start with the Ruby track, I didn't want to introduce error
handling here.

The wikipedia article about the Hamming distance says that the behavior is undefined if
the strings are of unequal length. I don't necessarily think that this means that a particular
implementation _shouldn't_ specify an error, only that it's OK to leave it undefined.

This will also make it possible to bring up the idea of edge cases and error handling in the
discussions on the site.

Closes #44 and #31.
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

Successfully merging this pull request may close these issues.

4 participants