Problem 46122. Find the nth term in the digit inventory sequence
Cody Problems 40, 55, and 594 deal with the "look and say" sequence, in which each term describes the term before it. For example, the first few terms of sequence A001151 in the Online Encyclopedia of Integer Sequences are
8, 18, 1118, 3118, 132118, 1113122118
The second term is "one 8". The third is "one 1, one 8". The fourth is "three 1's, one 1". Et cetera. That is, each term is constructed by naming the runs of digits in the previous term.
In the sequence that I will call the "digit inventory sequence", each term is constructed as an inventory of the digits. If the first term is 8, then the first six terms are
8, 18, 1118, 3118, 211318, 31121318
The first four terms match those in the look-and-say, but the next terms differ. For example, because the fourth term has two 1's, one 3, and one 8, the fifth term is 211318.
Write a function that takes the first term of a digit inventory sequence and finds the nth term. Output the term as a character string.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers18
Suggested Problems
-
Given a window, how many subsets of a vector sum positive
851 Solvers
-
4552 Solvers
-
85 Solvers
-
8902 Solvers
-
634 Solvers
More from this Author277
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!