Problem 40 optimization

Reduced solve time from 2 minutes 7 seconds to under a 3rd of a second
by switching from string to stringbuilder
Misc.