Each new number is composed of digit pairs which count the consecutive occurences of digits in the last number:
1 2 1 -> 11 12 11 (one '1', one '2', one '1')
111 2 11 -> 31 12 21 (three '1's, one '2', two '1's)
3 11 22 1 -> 13 21 22 11 (one '3', two '1's, two '2's, one '1')
so the next number should be:
1 3 2 1 22 11 -> 11 13 12 11 22 21 = 111312112221
I first encountered this sequence as a method of compressing long strings of repeated numbers:
888888884444444999222222211111116644444 ->
88743972712654
Though obviously it's not a good choice for compressing something like:
123456789123456789 ->
111213141516171819111213141516171819
chr0
----
perl -le'$$=substr(%{*::}->{_},2,1);print+(map{$$++for(1..$_);$$}(2,5,10)),$|'
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.