fork download
  1. #!/usr/bin/perl
  2. use 5.016;
  3. use warnings;
  4.  
  5. sub chunk {
  6. my $n = shift;
  7.  
  8. my @l;
  9. foreach(0 .. $#_){
  10. push @{$l[$_ / $n]}, $_[$_];
  11. }
  12.  
  13. return @l;
  14. }
  15.  
  16. sub len { length($_[0]) > 1 ? length($_[0]) : '' }
  17.  
  18. sub _f { map{ $_->[1] . len($_->[0]) } chunk(2, shift =~ m/\G((.)\2*)/g) }
  19.  
  20. sub f { length $_[0] ? _f($_[0]) : 0 }
  21.  
  22. while(<STDIN>){
  23. say f($_);
  24. }
  25.  
Success #stdin #stdout 0s 3736KB
stdin
aaaaaaaaaabbbbbbbbbbbbcccccccddddddddddeeeeeeefffffffffghiiiiiiiii

stdout
a10b12c7d10e7f9ghi9
0