Completed script for problem 1.