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.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #41: Pandigital prime
You are viewing a single comment's thread. Return to all comments →
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.