Created solution for problem 53, runs acceptably fast