All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Conjoined Twins (Posted on 2023-10-20) Difficulty: 3 of 5
Determine the smallest pair of twin primes A and B, such that when concatenated, A and B will contain all 10 decimal digits.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
improved code Comment 3 of 3 |
My original code was just looking for the smallest; it did not properly account for all the conditions.
I corrected it and removed the break statement so now it finds the same 69 solutions (of 8-digit numbers) as Charlie found.

At first I was forcing the smaller 8-digit prime to have no repeat digits, but there is at least one solution that ends in a double 9, so I modified to account for that.
Ran in about 4 seconds.

-----
for i in range(10000009,100000000,10):
    s = str(i)
    if '1' in s:
        continue
    if s[6] == '9':
        setlength = 7
    else:
        setlength = 8
    if len(set(s)) != setlength:
        continue
    if str(int(s[6])+1) in s:
        continue
    if isprime(i) and isprime(i+2):
        if len(set(str(i)+str(i+2)))==10:
            print('({}, {})'.format(i, i+2))

  Posted by Larry on 2023-10-20 13:37:20
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (10)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information