Monday 19 September 2022

Look and Count Sequence

On February 10th 2017, I posted about the Look and Say Sequence. After rereading that post, I thought about a variation on that idea and I've called it the Look and Count Sequence. Let's use 1 and example. To begin with there is only one 1 and so we write 11. Now there are two ones and so we write 21. So far it is the same as the Look and Say Sequence.

Here's where it differs. Instead of saying "one two and one one" (1211), we count how many ones, how many twos etc. in order from lowest to highest. Thus 21 becomes "one one and one two" (1112). Now we have "three ones and one two" (3112) which in turn becomes "two ones, one two and one three" (211213). I've written an algorithm to generate the sequence of numbers that result from using 1 as the starting point (permalink). Here it is:

1, 11, 21, 1112, 3112, 211213, 312213, 212223, 114213, 31121314, 41122314, 31221324, 21322314, 21322314

As can be seen the sequence quickly terminates when it reaches 21322314. What about using 2 as the starting point? The result is this sequence enters the one above at the number 1112:

2, 12, 1112, 3112, 211213, 312213, 212223, 114213, 31121314, 41122314, 31221324, 21322314, 21322314

Trying 3, it can be seen that again the sequences overlap and the end result is the same.

3, 13, 1113, 3113, 2123, 112213, 312213, 212223, 114213, 31121314, 41122314, 31221324, 21322314, 21322314

Trying 4, the same end result is reached and even more quickly.

4, 14, 1114, 3114, 211314, 31121314, 41122314, 31221324, 21322314, 21322314 

With 5, the result must be different and it is but the sequence again quickly terminates.

5, 15, 1115, 3115, 211315, 31121315, 41122315, 3122131415, 4122231415, 3132132415, 3122331415, 3122331415

When we investigate 6, 7, 8 and 9, it can be seen that the pattern in the same.

6, 16, 1116, 3116, 211316, 31121316, 41122316, 3122131416, 4122231416, 3132132416, 3122331416, 3122331416

7, 17, 1117, 3117, 211317, 31121317, 41122317, 3122131417, 4122231417, 3132132417, 3122331417, 3122331417

8, 18, 1118, 3118, 211318, 31121318, 41122318, 3122131418, 4122231418, 3132132418, 3122331418, 3122331418

9, 19, 1119, 3119, 211319, 31121319, 41122319, 3122131419, 4122231419, 3132132419, 3122331419, 3122331419

What if we take an arbitrary and larger number, let's say 78651154? The result is a two step loop (5142131415261718 --> 6122132425161718 --> 5142131415261718):

78651154, 211425161718, 51221415161718, 61221425161718, 51321415261718, 5122131425161718, 6132131425161718, 6122231415261718, 5142131415261718, 6122132425161718, 5142131415261718

Even if we take an unusual number like 999999999999, the result is also a two step loop:

999999999999, 129, 111219, 411219, 31121419, 4112131419, 5112132419, 412213141519, 512213241519, 413213142519, 412223241519, 314213241519, 412223241519

So far I've not considered numbers with 0 as a digital. If we try 1004056906, the result is the same two step loop:

1004056906, 401114152619, 10511224151619, 10612214251619, 10513214152619, 1051221314251619, 1061321314251619, 1061222314152619, 1051421314152619, 1061221324251619, 1051421314152619

So it seems that, no matter what the starting number, the sequence of terms generated quickly terminates. This is true for even large numbers like:

101111011101100222222222222222222222222222222222

The steps leading to another two step loop are:
  1. 101111011101100222222222222222222222222222222222
  2. 50101332
  3. 2021122315
  4. 1031421315
  5. 104112231415
  6. 105122132415
  7. 104132131425
  8. 104122232415
  9. 103142132415
  10. 104122232415
It's interesting to explore what numbers set records for the number of steps required before they terminate. Here is what I found for the range of numbers up to 100,000 (permalink):

1 requires 13 steps
60 requires 14 steps
70 requires 15 steps
80 requires 16 steps
109 requires 17 steps
2008 requires 18 steps
2009 requires 20 steps
9009 requires 21 steps

No comments:

Post a Comment