Write a program that takes two integers as an input; the first can be any integer and the second is less than or equal to the number of digits in the first number. Let these numbers be a and b respectively.
The program will do the following
- Concatenate a minimal number of
1s to the end ofaso the number of digits inais divisible byb. - Split
aalong everybdigits. - Multiply the digits in each section together.
- Concatenate the products together (if one of the numbers is zero, then concatenate
0). - Repeat this process until a number with strictly fewer than
bdigits is formed. Print this as the output, as well as the number of the process is repeated. Units are not necessary, but some form of separation between the final number and number of iterations is.
In the following test cases, the individual steps are shown for the purpose of understanding. It is not necessary for your program to display the steps.
Test case 1
1883915502469, 3
Steps
1883915502469 //Iteration 1 188391550246911 188 391 550 246 911 64 27 0 48 9 64270489 //Iteration 2 642704891 642 704 891 48 0 72 48072 //Iteration 3 480721 480 721 0 14 014 //Iteration 4 0 Sample Output: 0, 4
Test case 2
792624998126442, 4
Steps
792624998126442 //Iteration 1 7926249981264421 7926 2499 8126 4421 756 648 96 32 7566489632 //Iteration 2 756648963211 7566 4896 3211 1260 1728 6 126017286 //Iteration 3 126017286111 1260 1728 6111 0 112 6 01126 //Iteration 4 01126111 0112 6111 0 6 06 Sample Output: 06, 4
The program must return an error (or just not print anything) if b≥len(a).
This is code golf, fellas. Standard rules apply. Shortest code in bytes wins.