Completed question from programming quiz I was unable solve in the allotted time