So I'm slowly making my way through Project Euler. I am currently on
Problem 6. Having read that not all problems are solvable by brute force, I have begun by multiplying out (a+b+c+d+e+f+g+h+i+j)^10, giving me a^2 + b^2 + c^2 ...... + j^2 + 2ab + 2bc + 2ac + 2bd ..... + 2ij (do you see the
pattern?). Then, if I do what the problem asks me to do and take away the sum of the squares of all the terms, I'm just left with the latter bit, all terms of which consist of 2 and a combination of two of the letters, e.g. "2bd" (there are 10C2 of those, aka 45). My plan is to get a loop to pair up those numbers in the combinations, putting * between them (making "2 * b * d"), put all of those into an array and return it, join the array items up into a long
string, then chuck the whole thing into eval() and get my result. Before I even start writing my code, I want to ask - will that work? And does
Java offer a better way of solving that problem?