# Project Euler #98: Anagramic squares

# Project Euler #98: Anagramic squares

+ 0 comments Only test case 10 fails due to timeout error. I tried submitting in pypy3 too. Annoying. Any help?

+ 0 comments why is test case 0 is failing and rest all are passing? isn't the testcase with N=4? i am able to test my code for N=4 with correct answer of 9216. I am not sure what am i missing.

+ 1 comment **Hints**:1) For each N, you only need to loop from 10^((N-1)/2) to 10^(N/2). For example: N=4, i runs from 31 to 100. Then take i^2. That saves a lot of time complexity compared with i running from 1000 to 10000 and then taking square root.

2) A nice trick to store all permutations in any permutation problems: create a dictionary, convert satisfied number as a sorted key. For example: {'1269': [1296, 2916, 9216]}, where '1269' is sorted key of 1296, 2916 and 9216

+ 0 comments I followed a simpler approach, I precomputed all the answers and stored it, and just responded to the queries...

for the hash function i used the descending order of digits.

+ 1 comment 961 , 9216 , 96100 , 501264 , 9610000 , . , . , . , . , . , .

Sort 19 Discussions, By:

Please Login in order to post a comment