Homework 3 for Johns Hopkins R Langauge Programming course