Solution to the first programming assignment