You are viewing a single comment's thread. Return to all comments →
The only way (I've found) to pass all test in Python is to precompute all pandigital primes and then answer queries using this array.
Python 3 is definetly is not the best choise for this task. My Python code timeouted at 10s and same algorithm in Go works 0.28s in wors case
I guess this is linked to your pandigital generation.
I use string permutations to create all pandigital numbers.
Create all string permutations of "12" "123" "1234" ...
Then just check primality for each of those generated numbers.
Each case takes me 2.5 seconds except one (TC 4 I think) which is cleared in 5s
I also always use memoization on each problem because there will always be one case causing trouble.