in reply to Sorting and ranging problems...
I think I Tee-off at 198 chars... Which if you exclude the length of the input string is 163 (counting quotes still though)
Oh yeah, its strict safe as well... But somehow, if this is homework, I doubt your prof's gunna like this one....$"=",";@0=sort{$a<=>$b}split/,/,'1089,3,4,5,6,7,99,832,1087,831,1088'; +$_= ":@0";1while s;:((\d+)(-(\d+))?),(\d+);$4?$5-$4==1?":$2-$5":",$1:$5":( +$5- $2==1)?":$2-$5":",$2:$5";e;y/:/,/d;s/^.//;print;
:-)
Note
I took the liberty of assuming the numbers would be unique. Oh and thanks to Chemboy for the golf language tips :-)
Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)
|
|---|