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
1
s to the end ofa
so the number of digits ina
is divisible byb
. - Split
a
along everyb
digits. - 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
b
digits 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)
. Also, b
cannot equal 1 or the program will result in an infinite loop.
This is code golf, so standard rules apply. Shortest code in bytes wins.
a
and are also included in the output? \$\endgroup\$