Given a positive integer j greater than 1, the corresponding Collatz
sequence is produced by repeatedly applying f to j (and continues even after we reach 1). The function f behaves as follows:
{ x/2 if x is even
f(x) = {
{ 3x+1 if x is odd
Suppose someone began with the value y and has started (but not
necessarily finished) generating the Collatz sequence. Each time they
apply f they write down 'E' or 'O' to denote whether the argument was even or odd,
respectively. Given the String s they have written down,
you must return a String of the form (quotes for clarity) "ak+b". Here a
and b are integers with no extra leading zeros. The returned string
must make the following set the collection of all possible numbers
that could have begun the sequence:
P = { ak + b | k >= 0 and ak + b > 1}
If there are multiple possible return values, choose the one with b minimal. |