Algorithm final exam solution. Pseudo-code is not required.