Project Euler 92: count sum-squared-digits chains that reach 89
I guess the idea behind using permutations is that any permutation of the same digits will result in the same squared sum. However... in that case, shouldn't we simply calculate the squared sum and cache that?
It appears that we're only caching the permutations of the digits at the end of the chain. i.e. we'll only ever end up with 1, 89 and 98 in the map! We should probably be caching all the values in the chain up to the final result.
#include &lt;string&gt; for std::to_string.
Converting to and from std::string is probably quite slow. We can use simple integer arithmetic to extract the individual digits.
The implementation of sumOfDigitsSquared is clearly incorrect with basic testing.