Added solution to Euler's 42nd problem - needs refactoring