+ 4

CHALLENGE : Pandigital Prime Number

What is a pandigital number ? An n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. Challenge : Find all the n-digit pandigital prime numbers (n given by the user). Have fun and enjoy coding ! 😉 // Problem from Project Euler See my algorithm in Python (not optimised enough to run on SoloLearn). https://code.sololearn.com/c03Eb68ykIqM/?ref=app

1st Sep 2017, 5:45 PM
Oberyin
Oberyin - avatar
19 odpowiedzi
1st Sep 2017, 2:09 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 7
Krishna's algorithm is amazing! My one :( https://code.sololearn.com/cEZ6nhyDMFU6/?ref=app
1st Sep 2017, 7:47 PM
Shamima Yasmin
Shamima Yasmin - avatar
2nd Sep 2017, 12:23 AM
LukArToDo
LukArToDo - avatar
+ 5
@Oberyin Thanks for the challenge. I enjoyed :)
2nd Sep 2017, 6:00 AM
LukArToDo
LukArToDo - avatar
2nd Sep 2017, 3:32 AM
ysraelcon
ysraelcon - avatar
+ 2
@LukArToDo and @ysraelcon Really good job !
2nd Sep 2017, 4:29 AM
Oberyin
Oberyin - avatar
+ 2
Oberyin please find my contribution to your challenge written in Python. While this runs well on a pc the code playground seems to restrict the time so that it will not run for numbers with 7-9 digits. All the same I hope the code is of interest. https://code.sololearn.com/cejsNKgWvwj3/#py
2nd Sep 2017, 2:51 PM
Richard Myatt
Richard Myatt - avatar
+ 1
@Haris Try it on a computer, n=7 worked for me.
1st Sep 2017, 6:28 PM
Oberyin
Oberyin - avatar
+ 1
@Shamima Yasmin Good job ! :)
1st Sep 2017, 7:59 PM
Oberyin
Oberyin - avatar
+ 1
@Yash Thatte Well done ! Mine also needs to be optimised. On my computer, i can go up to 10 but on SoloLearn, it works only up to 6.
2nd Sep 2017, 1:21 PM
Oberyin
Oberyin - avatar
0
@Krishna Teja Yeluripati Well done ! I hope it wasn't too easy !
1st Sep 2017, 2:16 PM
Oberyin
Oberyin - avatar
0
@Krishna Teja Yeluripati Your code seems to crash for input: 7 & 9. For other cases works fine. (tested on mobile)
1st Sep 2017, 5:54 PM
Haris
Haris - avatar
0
Here you go. Checks for valid input https://code.sololearn.com/ceq0o28i60wg/?ref=app
13th Sep 2017, 10:17 AM
Vari93
Vari93 - avatar
0
@Vari93 I just checked for 4 and it seems that your algorithm isn't working properly ^^
13th Sep 2017, 10:36 AM
Oberyin
Oberyin - avatar
0
@Oberyn That's because it's checking all primes 1 - 4, so only 2 and 3. I set it up where it generates all primes from 2 to user given input. It then goes through all of the primes, finds it's length then checks if the numbers 1 - X, X being the length, is in the number.
13th Sep 2017, 10:44 AM
Vari93
Vari93 - avatar