Challenge:
Create a program that takes input of a positive non-zero integer and outputs the 4 next numbers in the sequence described below.
Note: Checking if the input is actually a positive non-zero integer is not necessary
Sequence:
Every number in this sequence (apart from the first, which is the input) shall be composed of n digits, where n is an even number. If we split the number to n/2 pairs, for each pair, the first digit should be the amount of times the second digit appeared in the previous number
Visual explanation:
Consider this example "sequence starter" or input 6577
The next number in the sequence should look like this 161527
Because the input has 1 "6", 1 "5" and 2 "7"s.
If input has too many digits (more than 9 of a single digit) you wouldnt be able to get a correct output
Example: 111111111111
(12 1's)
Next number in sequence has to describe 12 1's. Thus we split it into 9 1's and 3 1's (sum 9+3 = 12)
Next number: 9131
You should iterate 4 times for the input, and output it (either return a list/array of 4 integers, or output it by seperating them with a space, newlines are also acceptable)
"The number can be written in a lot of ways, how do I write it?":
If you think about it, the example input 6577
can also be written as 271516 (two 7's, one 5, one six). However this is non-valid output. You should iterate the number left to right. Thus 161527. If it was 7657
you would iterate the amount of 7's, then amount of 6's then amount of 5's, thus valid output would be 271615
Example I/O:
Input:75
Output:1715 211715 12311715 4112131715
Input:1
Output:11 21 1211 3112
Input:111111111111
(12 1's)
Output:9131 192113 31191213 23411912
This is unlike the "Say what you see" question, because the sequences are different: https://oeis.org/A005150 <- This one returns numbers like this:
Input: 1211 Output: 111221
While the sequence I'm asking for would do
Input: 1211 Output: 3112
The two sequences are different and require different algorithms.
My asked sequence: https://oeis.org/A063850
"Possible duplicate" sequence: https://oeis.org/A005150
Important specification:
Since it wasnt clear enough for some people who tried to answer this question, the correct output for k chars where k > 9 is not "kc" (where c is char) but 9c(k-9)c etc. Thus correct output for 12 1's isn't 121
(12 1) but 9131
(9 1's, (12-9) 1's and so on)
If in doubt, your code is wrong if it ever outputs a number with an odd amount of digits (like 121), it should have output of even digit numbers due to the nature of the sequence.
This is code-golf thus code with least bytes wins.
1111111111111111111
(19 1's) \$\endgroup\$23411912
instead of23411219
? \$\endgroup\$