Bug’s still here - I guessed a number that was one off and the game hung.
I like luvrhino’s suggestion, and I think it might actually be possible to get the same effect without special cases, just by capping the search space. By the time you get to (x-500) is a 10th power
, the only possible value for x-500
is 1, because the 10th power of 2 is more than three digits - so the search for the highest power that works can always stop at 10. Presumably similar “at this point the answer is unique” cutoffs can apply to other criteria.