-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
Levenshtein-distance: New exercise suggestion #1634
Levenshtein-distance: New exercise suggestion #1634
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick glance, I see some minor formatting changes that would be good for the canonical data.
It would be a nice if the opening comment to this PR gave some background information regarding this exercise. Also, presently, adding new exercises is on hold in a general sense for the site. However, it doesn't mean that individual language tracks can't still add this exercise now if they so choose. |
Thanks a lot for reviewing of my PR! I tried to follow your suggestions |
We can't merge this until #1560 lifts, but it's a great idea for an exercise. My one thought, should it just be |
As of f18d301, the cases in this file are correct, according to: require 'json'
require_relative '../../verify'
# https://web.archive.org/web/20180612143641/https://bitbucket.org/clearer/iosifovich/
def lev_dist(shorter, longer)
shorter, longer = [longer, shorter] if shorter.size > longer.size
left = 0
right = -1
left += 1 while shorter[left] &.== longer[left]
right -= 1 while left - right <= shorter.size && shorter[right] == longer[right]
buf = Array.new(shorter.size + 2 - left + right, 0)
#puts "compare #{left} to #{right}: #{shorter[left..right]} vs #{longer[left..right]} (#{buf.size})"
(left..(longer.size + right)).each { |i|
clong = longer[i]
tmp = buf[0]
buf[0] += 1
(1...buf.size).each { |j|
cshort = shorter[left + j - 1]
r = buf[j]
buf[j] = [
r + 1,
buf[j - 1] + 1,
tmp + (clong == cshort ? 0 : 1),
].min
tmp = r
}
}
buf[-1]
end
json = JSON.parse(File.read(File.join(__dir__, 'canonical-data.json')))
verify(json['cases'], property: 'distance') { |i, _|
lev_dist(i['from'], i['to'])
} |
Closed and re-opened to make CI run. |
@marcelritzschke Are you still interested in working on this PR? If so, I've created a branch that adds four new commits that get your PR up-to-date with the latest specs: https://github.com/exercism/problem-specifications/commits/exercise-levenshtein-distance You chould cherry-pick those commits onto your branch to update your PR. |
This appears abandoned. I'll close this out. If you still want to work on this, we can reopen. |
No description provided.