Problem 46571. Characterize the final state of the digit inventory sequence
Cody Problem 46122 involved a counting sequence that I called the digit inventory sequence, in which each term provides an inventory of the digits of the previous term. If the initial number of the sequence is 24, then the sequence is
24, 1214, 211214, 312214, 21221314, 31321314, 31123314, 31123314, ...
For example, the third term provides an inventory of the second: two 1's, one 2, one 4. Notice that starting with 24 leads to a steady state after 7 terms because all subsequent terms are equal to the seventh (i.e., 31123314).
However, the final state is not necessarily a steady state. If the starting number is 210, then the sequence is
210, 101112, 104112, 10311214, 1041121314, 1051121324, 104122131415, 105122132415,
104132131425, 104122232415, 103142132415, 104122232415, 103142132415, ...
The tenth and eleventh terms repeat indefinitely. In other words, the repeated terms start at term 10, and they have a period of 2.
Write a function to determine the number of the term at which the final state begins and the period of the repeated terms.
Solution Stats
Problem Comments
-
5 Comments
Show
2 older comments
William
on 20 Sep 2020
Rats. My solution got all the problems right except the last. How is that possible?
ChrisR
on 22 Sep 2020
William, our results differ for a starting value of 570. I'm not sure why yet.
ChrisR
on 22 Sep 2020
William, I think I see the reason for the difference now. Let me know if you want a hint.
William
on 3 Oct 2020
Aha! I see the problem with 570. Very clever of you to include a case like that!
ChrisR
on 3 Oct 2020
Thanks but I'd say I was more lucky than clever. A run of periods drew me to that range. You're right that the case of 570 is a good one.
Solution Comments
Show commentsProblem Recent Solvers13
Suggested Problems
-
1714 Solvers
-
1584 Solvers
-
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
1788 Solvers
-
62 Solvers
-
Generate a list of composite numbers
46 Solvers
More from this Author280
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!