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

Home > Numbers
24 Four Digit Integers Puzzle (Posted on 2024-12-29) Difficulty: 3 of 5
A, B, C, and D represent four different digits that can be combined to yield 24 different four-digit integers.

These 24 integers have the following properties:

  • 4 are primes.
  • 7 are the products of two different odd primes.
  • 1 is the square of a prime.
  • 8 are divisible by 2 but not by 4.
  • 2 are divisible by 4 but not by 8.
  • 1 is divisible by 8 but not by 16
  • 1 is divisible by 16.
Determine the values of A, B, C, and D.

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer solution Comment 3 of 3 |
8431

------
from itertools import combinations
from itertools import permutations
import sympy
def isprime(n):
    return sympy.isprime(n)
primes4 = [i for i in range(1001,10000,2) if isprime(i)]
condition2primes = [i for i in range(3,3333,2) if isprime(i)]
prod2oddPrimes = []
for co in combinations(condition2primes,2):
    myproduct = co[0]*co[1]
    if myproduct > 1000 and myproduct < 10000:
        prod2oddPrimes.append(myproduct)

squaresOfPrime = [i**2 for i in range(33,100,2) if isprime(i)]

by2butnotby4s = [i for i in range(1000,10000,2) if i%4==2]
by4butnotby8s = [i for i in range(1000,10000,4) if i%8!=0]
by8butnotby16s = [i for i in range(1000,10000,8) if i%16!=0]
divby16 = [i for i in range(1008,10000,16)]

for comb in combinations('0123456789', 4):
    conditions = [0 for i in range(7)]
    for perm in permutations(comb):
        n = int(''.join(perm))

        if n in primes4:
            conditions[0] += 1
        if n in prod2oddPrimes:
            conditions[1] += 1
        if n in squaresOfPrime:
            conditions[2] += 1
        if n in by2butnotby4s:
            conditions[3] += 1
        if n in by4butnotby8s:
            conditions[4] += 1
        if n in by8butnotby16s:
            conditions[5] += 1
        if n in divby16:
            conditions[6] += 1
        if conditions == [4,7,1,8,2,1,1]:
            print(n)

  Posted by Larry on 2024-12-29 11:44:22
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 (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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