We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
If you are having timout issues, I recommend implementing sieve to get the relevant prime numbers, and using itertools permutations. The key is not to run itertools on every prime. As you go along, apply the same permutation list to all the primes in the list to optimize speed. I recommend splicing only the larger primes. Good luck!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #49: Prime permutations
You are viewing a single comment's thread. Return to all comments →
If you are having timout issues, I recommend implementing sieve to get the relevant prime numbers, and using itertools permutations. The key is not to run itertools on every prime. As you go along, apply the same permutation list to all the primes in the list to optimize speed. I recommend splicing only the larger primes. Good luck!