My solution to this coding test :)