Golf a sub that given a sorted list of integers as input, produces (correct) output as required by the OP in Problems with looping through an array including the grouping.
Rules: No strict, No warnings, $/="\n" (-l implied).
Can you beat 77?
sub ject{
# 1 2 3 4 5 6 7 8
#234567890123456789012345678901234567890123456789012345678901234567890123456789
$l=$n=$c=0;map{($l eq$_ or$n=0),$l=$_ and print!$n?$/:'',++$c,") $_-",++$n}@_
}
|
|
|---|