From: Bryan Richardson Date: 2008-08-07T06:47:30+09:00 Subject: Re: Need help detecting overlapping ranges Thanks to all who replied! I took the main advice of all of your posts to be "don't convert ranges to arrays stupid!!!" and also "don't do this recursively stupid!". :) With that in mind, here's what I came up with (I didn't want to just copy someone's code... I don't learn anything that way!) -- it seems to be much faster: def merge_outages ranges = @failed.outages.sort { |a,b| a.first <=> b.first } outages = Array.new while !ranges.empty? range = ranges.shift loop do if ranges.empty? break else if (range.last + 1) >= ranges.first.first range = (range.first..ranges.first.last) ranges.shift else break end end end outages << range end return outages end What do you guys think of this approach? Am I overlooking something that you guys suggested? -- Thanks! Bryan -- Posted via http://www.ruby-forum.com/.