working solution to part one of programming assignment 4