Skip to main content
The National Cipher Challenge

Programming

A Tale of 2 Secrets Forums T.E.M.P.E.S.T. Programming

Tagged: 

Viewing 8 posts - 31 through 38 (of 38 total)
  • Author
    Posts
  • #112193
    F6EXB_the_frenchy
    Participant

    #112187

    Because I check whether each substring of 4-digit prime numbers is in the list of 1, 2, or 3 digits prime numbers.

    #112199
    AndGiggles
    Participant

    @ByteInBits I seem to recall this being one of the early Project Euler problems. Did you find this problem there or from elsewhere?

    #112424
    ByteInBits
    Participant

    @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]

    #112157
    Robb27
    Participant

    @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 prime

    Number 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):
    continue

    s = 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()

    #112180
    F6EXB_the_frenchy
    Participant

    @ByteInBits
    #112155

    I 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

    #112192
    ByteInBits
    Participant

    [Think there might be a typo in this one confusing X and Y? Might be worth checking and posting again. Harry]

    #112194
    ByteInBits
    Participant

    F6EXB_the_frenchy
    #112193

    Now I understand, thank you 😉

    #112430
    AndGiggles
    Participant

    I 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

Viewing 8 posts - 31 through 38 (of 38 total)
  • You must be logged in to reply to this topic.
Report a problem