Solution to Prog ass 2 original