Substring Diffing Ruby Challenge

first = 'Joe went to the store and bought 2 loaves of bread'
second = 'Joe and I went to the market and bought 3 loaves of bread
and butter'

assert_equal [4..9, 21..29, 57..68], diff(first, second) # diff()
returns a list of Ranges spanning the position of edits or insertions

Anyone know an algorithm (or code) that can make that work?

S. Robert James wrote:

first = 'Joe went to the store and bought 2 loaves of bread'
second = 'Joe and I went to the market and bought 3 loaves of bread
and butter'

assert_equal [4..9, 21..29, 57..68], diff(first, second) # diff()
returns a list of Ranges spanning the position of edits or insertions

Anyone know an algorithm (or code) that can make that work?

I extended Austin Ziegler's LCS/Diff library to do just this for my project

LCS/Diff:
http://raa.ruby-lang.org/project/diff-lcs/

Weft QDA code that does it:
http://viewvc.rubyforge.mmmultiworks.com/cgi/viewvc.cgi/trunk/weft-qda/lib/weft/diff.rb?root=weft-qda&view=co

The 'transform' method accepts two strings and returns an array of 'Transformation' objects, each representing a single insert/delete/change

hth
alex