Solution to prog ass 2