Add code solutions for part of problem 4