"""
https://edabit.com/challenge/JPdKrztrcL7DpooDr

A Collatz sequence is generated by repeatedly applying the following rules to an
integer and then to each resulting integer in turn:

    If even: divide by 2.
    If odd: multiply by 3, then add 1.

The Collatz conjecture states that, for any initial positive integer, you will
eventually reach the number 1.

Write a function that, for an initial positive integer n, returns a list
containing 2 values:

    The number of times the Collatz rule has to be applied until you reach 1.
    The maximum number reached in the process.

collatz(17) ➞ [12, 52]
# Because 17 – 52 – 26 – 13 – 40 – 20 – 10 – 5 – 16 – 8 – 4 – 2 – 1
# takes 12 steps and 52 is the highest number reached.
"""


def collatz(n: int) -> list:
    L = []
    if n == 1:
        return [0, 1]
    while n != 1:
        if n % 2 == 0:
            n = n // 2
        else:
            n = 3 * n + 1
        L.append(n)
    return [len(L), max(L)]


assert collatz(1) == [0, 1]
assert collatz(3) == [7, 16]
assert collatz(9) == [19, 52]
assert collatz(27) == [111, 9232]
assert collatz(81) == [22, 244]

print('Success')