Solution for programming assignment