#!/usr/bin/perl -w

use v5.16;
use strict;

my $in = 1321131112;

for (1 .. 40) {
	my $out = '';
	1 while $in =~ s/^(.)(\1*)/$out .= (1+length($2)).$1;''/e;
	say $out;
	$in = $out;
}
say length $in;

