On Sun, Jul 11, 2004 at 07:37:27PM +0900, George Ogata wrote:
> > Example:
> > [1,2,3,4,6,7,8,11,12,15,16,17] ==> [1..4,6..8,11,12,15..17]
> 
> Interesting one to golf with:
> 
> a.each_index{|i|a[i..j=i+2]==[x=a[i],x+1,x+2]and(0while a[j]+1==a[j+=1];a[i..j-=1]=a[i]..a[j])}

Golfing a bit on #ruby-lang, exoticorn & I got

s=[];a.map{|x|(l=s[-1])&&x-l[-1]<2?l<<x:s<<[x]};s.map{|f|f[2]?f[0]..f[-1]:f}.flatten

Note that whereas your solution is in-place, this one creates a new
array. It is easier to specify the minimum range size, too.

-- 
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

You will not censor me through bug terrorism.
	-- James Troup