Solution 5

Pretty easy, could do with optimisation, however.