The final day! Of course it hase to be public-key cryptography…

Part 1

Well the first part is pretty straightforward, just implement the algorithm described to find the secret key (a.k.a. the number of loops):

transform(n, subj) = (n*subj)%20201227

function loops(key, subject=7)
    n = subject
    i = 1
    while n != key
        n = transform(n, subject)
        i += 1
    end
    return i
end

And then to calculate the encryption key:

function encrypt(key, loops)
    n = 1
    for i in 1:loops
        n = transform(n, key)
    end
    return n
end

Part 2

Merry Christmas and Happy New Year!

Now I just need to finish days 19, 20, 22, and 23