Programming
A Tale of 2 Secrets › Forums › T.E.M.P.E.S.T. › Programming
Tagged: #answer
- This topic has 30 replies, 9 voices, and was last updated 2 days, 9 hours ago by ByteInBits.
-
AuthorPosts
-
31st October 2025 at 11:20 pm #112193F6EXB_the_frenchyParticipant
#112187
Because I check whether each substring of 4-digit prime numbers is in the list of 1, 2, or 3 digits prime numbers.
1st November 2025 at 12:43 pm #112199AndGigglesParticipant@ByteInBits I seem to recall this being one of the early Project Euler problems. Did you find this problem there or from elsewhere?
4th November 2025 at 5:40 pm #112424ByteInBitsParticipant@MyGiggle
From another source. Notice that like the source I asked for the only other 4 digit number.
However I relooked at PE and you are correct it is PE#37 and that is asking to sum all such numbers (11 of them) as the answer.
Do you engage with the PE questions?
I have solved all of the first 50, plus about 6 other scattered numbers.
Its nice to see all those tick marks 😉I completed #37 on Fri, 25 Apr 2025,
[Edited by Harry – Sorry, had to remove the info here, hope you understand, Harry]6th November 2025 at 2:40 pm #112157Robb27Participant@ByteInBits #112155
I don’t profess to be the best python programmer, but this worked for me: 3797 as well as 3137 per your original post.
Number 3137 is prime and meets the conditions:
Suffix 7 is prime
Suffix 37 is prime
Suffix 137 is prime
Prefix 3 is prime
Prefix 31 is prime
Prefix 313 is primeNumber 3797 is prime and meets the conditions:
Suffix 7 is prime
Suffix 97 is prime
Suffix 797 is prime
Prefix 3 is prime
Prefix 37 is prime
Prefix 379 is prime`from sympy import *
def check_prime():
for p in range(1000, 10000):
if not isprime(p):
continues = str(p)
prefixes = [int(s[:i]) for i in range(1, 4)]
suffixes = [int(s[-i:]) for i in range(1, 4)]# Check if all prefixes and suffixes are prime
if all(isprime(x) for x in prefixes + suffixes):
print(f”\nNumber {p} is prime and meets the conditions:”)
for x in suffixes:
print(f” Suffix {x} is prime”)
for x in prefixes:
print(f” Prefix {x} is prime”)check_prime()
6th November 2025 at 2:41 pm #112180F6EXB_the_frenchyParticipant@ByteInBits
#112155I have two others numbers with this property.
I did wonder if that would happen! Makes it interesting to think about how to think about the problem. Harry
6th November 2025 at 2:42 pm #112192ByteInBitsParticipant[Think there might be a typo in this one confusing X and Y? Might be worth checking and posting again. Harry]
6th November 2025 at 2:42 pm #112194ByteInBitsParticipantF6EXB_the_frenchy
#112193Now I understand, thank you 😉
6th November 2025 at 2:43 pm #112430AndGigglesParticipantI did most of the first hundred when I was in high school (there were a few I couldn’t figure out) to procrastinate from studying for my exams, but university took over and I haven’t looked at them in years. Now I suppose I am using the NCC as a way to procrastinate from doing my representation theory homework. My problem with this competition has always been that the interesting challenges are always scheduled for when I have exams, so I will need to decide in a month or so if I would rather have decent grades or if I want to solve 10B (it will be a tough choice).
I hope you make the right choice! Wouldn’t want to ruin your career! Harry
-
AuthorPosts
- You must be logged in to reply to this topic.