added code for assignment 1, parts A and B