On Tue, Sep 21, 2010 at 2:10 AM, F. Senault <fred / lacave.net> wrote:
> Hello everybody.
>
> =A0My
> goal is to find sequences in the numbers and join them with dashes :
>
>
>

This is not a complete solution but *maybe* it is something worth looking a=
t.
It depends on your specs.
I'll leave it to you to work out the details.

arr =3D [ '1', '2', '3', '4', '6', '7', '9', 'S1', 'S2' ]
s =3D ('1'..'20').to_a + ('S1'..'S5').to_a

t =3D []
s.each do |x|
  t << x if arr.include?(x)
  t << "*" if arr.include?(x) =3D=3D false
end

p t.join(" ").split("*").map{|y| y.strip.split(" ")}.select{|z| z.size
> 0}.map{|w| "#{w[0]}-#{w[-1]}"}

#> ["1-4", "6-7", "9-9", "S1-S2"]


Harry