fork download
  1. #!/usr/bin/perl
  2. use 5.016;
  3. use warnings;
  4.  
  5. my @memo = ("3");
  6.  
  7. sub f { $memo[$_[0]] //= f($_[0] - 1) =~ s/((\d)\2*)/length($1) . $2/ger }
  8.  
  9. foreach(0 .. 10){
  10. say f($_);
  11. }
  12.  
Success #stdin #stdout 0s 6132KB
stdin
Standard input is empty
stdout
3
13
1113
3113
132113
1113122113
311311222113
13211321322113
1113122113121113222113
31131122211311123113322113
132113213221133112132123222113