fork download
  1. #!/usr/bin/perl
  2. for (<STDIN>){
  3. my @b;
  4. for (/([-\d]+)/g) {
  5. @a = /(\d+)/g;
  6. $a[1] = $a[0] unless $a[1];
  7. @a = sort{$a<=>$b} @a;
  8. do {push(@b, $_) if 0<$_ and $_<=99999}
  9. for $a[0]..$a[1];
  10. }
  11. %h = map{$_=>1} @b;
  12. print '['.join(',', sort{$a<=>$b} keys %h)."]\n";
  13. }
Success #stdin #stdout 0s 4308KB
stdin
>>1
>>1-3
>>1,3
>>1-3,5,9-10
>>000000-000000001
>>289494
>>0-2,99998-100000
>>3,0-3,4,5,6,4,2-8
>>4-1
stdout
>>1
[1]
>>1-3
[1,2,3]
>>1,3
[1,3]
>>1-3,5,9-10
[1,2,3,5,9,10]
>>000000-000000001
[1]
>>289494
[]
>>0-2,99998-100000
[1,2,99998,99999]
>>3,0-3,4,5,6,4,2-8
[1,2,3,4,5,6,7,8]
>>4-1
[1,2,3,4]