Code and tests for the completion of Problems 1 and 2