fork download
  1. #!/usr/bin/perl
  2. @ds=("12_3", # 6s
  3. "313__", # 8s
  4. "4_35_1264_23_434", # 60s
  5. "123456789123456789", # 98s
  6. "88967472612377988186", # 149s
  7. "19898693316679441672", # 170s
  8. "93769682716711132249893" # ?
  9. );
  10. for (@ds) {
  11. $s = 0;
  12. while (/^(_*)(\d)(.*)$/) {
  13. $s += length($1) + $2;
  14. $_="_$3$1";
  15. for $i (1..$2) {
  16. $_=substr($_,1).substr($_,0,1);
  17. }
  18. }
  19. print ": $s\n";
  20. }
Success #stdin #stdout 0s 17496KB
stdin
Standard input is empty
stdout
12_3: 6
313__: 10
4_35_1264_23_434: 62
123456789123456789: 98
88967472612377988186: 151
19898693316679441672: 170
93769682716711132249893: 176