Login Register






[challenge] Largest prime palindrome filter_list
Author
Message
[challenge] Largest prime palindrome #1
Woo! More math challenges!

The purpose of this challenge is to find the largest prime palindrome under 1000.

By prime I mean, well, prime. By palindromic, I mean the number must be the same forwards and backwards.

Rules:
-No imports (at all. I didn't even use require 'prime')
-No more than one semicolon per line
-Under 4 lines for a 15 NSP prize

(btw, this one's a pain in the fucking ass to do from scratch)

Spoiler: My Solution (Ruby):
4 lines
Code:
def is_prime?(n); (2..n/2).none?{|i| n % i == 0} end def is_palindrome?(n); n == n.to_s.reverse.to_i end 1.upto(1000) { |n| is_prime?(n) && is_palindrome?(n) ? $val = n : nil } puts $val
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: [challenge] Largest prime palindrome #2
Code:
for x in range(1000, 0, -1): if (x > 1 and all(x % y for y in range(2, x))) == True and str(x) == str(x)[::-1]: print x; break

>929

[+] 1 user Likes Eclipse's post
Reply

RE: [challenge] Largest prime palindrome #3
(06-03-2015, 12:41 AM)Eclipse Wrote:
Code:
for x in range(1000, 0, -1): if (x > 1 and all(x % y for y in range(2, x))) == True and str(x) == str(x)[::-1]: print x; break

>929

Fuck.
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: [challenge] Largest prime palindrome #4
(06-03-2015, 01:32 AM)Chitoge Wrote: Fuck.

What's the next challenge? Tongue

Reply

RE: [challenge] Largest prime palindrome #5
(06-03-2015, 07:51 AM)Eclipse Wrote: What's the next challenge? Tongue

I'll open a new one when I get more NSP, ya greedy bastard Sarcasm
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: [challenge] Largest prime palindrome #6
I will be very honest, the rules of the challenges are pretty crap. Why ?

You're choosing a programming language you know well and which allows you to write less and do more where as others might have equal of better potential but due to your character, line or imports barrier they wont be able to do so or participate.

If I use C++ to solve this then I might use array or iterator imports which but the question on a whole will restrict a user to submit their code. The questions themselves are okay so I would recommend that you remove the shitty rules.

Thank you.
[Image: OilyCostlyEwe.gif]

Reply

RE: [challenge] Largest prime palindrome #7
(06-10-2015, 10:08 AM)Psycho_Coder Wrote: I will be very honest, the rules of the challenges are pretty crap. Why ?

You're choosing a programming language you know well and which allows you to write less and do more where as others might have equal of better potential but due to your character, line or imports barrier they wont be able to do so or participate.

If I use C++ to solve this then I might use array or iterator imports which but the question on a whole will restrict a user to submit their code. The questions themselves are okay so I would recommend that you remove the shitty rules.

Thank you.

Fair enough. I suppose I meant "No imports if not absolutely necessary".
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: [challenge] Largest prime palindrome #8
I shall do this after work. :^)

Reply