Functional, and fairly quick, full solution