Add a solution to the problem 78
Use a faster algorithm