in reply to Generating ranges of numbers

Sounds like homework.

Can you describe the algorithm you would use in your own words?

But most importantly: Why is "1 2 3" turned into "1:3" but "5 6 7" turned into "5:6 7"? What rule does that follow?

Replies are listed 'Best First'.
Re^2: Generating ranges of numbers
by nandymamith (Novice) on Jun 30, 2016 at 14:32 UTC

    Sorry Monk, my mistake. The OUTPUT should be in the below format :

    OUTPUT @ranges = ("1:3","5:7","9");