First solution to Programming Assignment