Refactoring problem 2 to include util and math files
Adding solution to problem 3