Write down a positive integer on a piece of paper:
886328712442992
Count up the number of even and odd digits, and the total number of digits:
10 5 15
String the digits of those three numbers together to make a new number:
10515
Perform the same operation on the obtained number:
1 4 5 ⟶ 145
And keep iterating:
1 2 3 ⟶ 123
You'll always arrive at the number 123.
In applying the procedure to determine the next number, leading zeros must dropped if the original number has no even digits. For example, if we start from the number 111, we determine the next number as
0 3 3 ⟶ 33 (not 033)
This makes a difference because 33 has no even digits (and gives 22 if we apply the procedure once more), whereas 033 does have one even digit (and would give 123 if we apply the procedure once more).
Write a function even_odd that takes an integer (int) $$n \in \mathbb{N}$$. The function must return a tuple containing two integers (int) that respectively indicate how many even and odd digits occur in $$n$$.
Write a function step that takes an integer (int) $$n \in \mathbb{N}$$. The function must return the number (int) obtained when applying the operation from the introduction to $$n$$ once.
Write a function steps that takes an integer (int) $$n \in \mathbb{N}$$. The function must return how often (int) the operation from the introduction must be applied before the number 123 is reached, if we start from $$n$$.
>>> even_odd(886328712442992)
(10, 5)
>>> even_odd(10515)
(1, 4)
>>> even_odd(145)
(1, 2)
>>> step(886328712442992)
10515
>>> step(10515)
145
>>> step(145)
123
>>> steps(886328712442992)
3
>>> steps(1217637626188463187643618416764317864)
4
>>> steps(0)
2
>>> steps(1)
5