Sinisterly
[challenge] Largest prime palindrome - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: [challenge] Largest prime palindrome (/Thread-challenge-Largest-prime-palindrome)



[challenge] Largest prime palindrome - Inori - 06-02-2015

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



RE: [challenge] Largest prime palindrome - Eclipse - 06-03-2015

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


RE: [challenge] Largest prime palindrome - Inori - 06-03-2015

(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.


RE: [challenge] Largest prime palindrome - Eclipse - 06-03-2015

(06-03-2015, 01:32 AM)Chitoge Wrote: Fuck.

What's the next challenge? Tongue


RE: [challenge] Largest prime palindrome - Inori - 06-03-2015

(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


RE: [challenge] Largest prime palindrome - Psycho_Coder - 06-10-2015

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.


RE: [challenge] Largest prime palindrome - Inori - 06-10-2015

(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".


RE: [challenge] Largest prime palindrome - Lain - 06-11-2015

I shall do this after work. :^)