Completed problem 29, not the greatest method though, will probably revisit this at some stage