Write a function compress_ranges
that receives an array of integers, and
returns a string where consecutive integers are replaced with a range showing
the first and last number in that run.
You can assume the array only contains distinct integers, and is always sorted in ascending order.
compress_ranges([4,5,6,7])
compress_ranges([1,3,4,5])
compress_ranges([-2,-1,0,1,3,5])
compress_ranges([-5,-4,-3,-1,1])
compress_ranges([-6,-3,-2,-1,0,1,3,4,5,7,8,9,10,11,14,15,17,18,19,20])
> compress_ranges([4,5,6,7])
=> "4-7"
> compress_ranges([1,3,4,5])
=> "1,3-5"
> compress_ranges([-2,-1,0,1,3,5])
=> "-2-1,3,5"
> compress_ranges([-5,-4,-3,-1,1])
=> "-5--3,-1,1"
> compress_ranges([-6,-3,-2,-1,0,1,3,4,5,7,8,9,10,11,14,15,17,18,19,20])
=> "-6,-3-1,3-5,7-11,14-15,17-20"