Added problem 12. A bit slow and messy but solves the problem in just under 1 minute