This is the final solution and reasoning behind the problem. Listed on line 5.