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

Home > Just Math
3 perfect squares (Posted on 2023-08-01) Difficulty: 4 of 5
I have written down three different 5-digit perfect squares, which :
* between them use five different digits.
* each of the five digits is used a different number of times
* the five numbers of times being the same as the five digits of the perfect squares.
* no digit is used its own number of times.
* If you knew which digit I have used just once, you could deduce my three squares with certainty.

What are the three perfect squares?

Source:
a math puzzle posted to the SAS Discussion Forum (from New Scientist magazine).

No Solution Yet Submitted by Ady TZIDON    
Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution No Subject | Comment 5 of 6 |
The total number of digits is 15, the frequencies of each digit are all different.  Since the sum:  1+2+3+4+5 = 15, the digits must be 1,2,3,4,5.

There are nine 5-digit squares composed only of the digits 1 through 5:
    [12321, 12544, 13225, 33124, 34225, 35344, 44521, 52441, 55225]

Combining these 3 at a time, doing a cumulative count of the number of occurrences of each digit, eliminating the ones where a digit's count is other than 1 through 5, and finally excluding those with 1 one, 2 twos, 3 threes etc leaves these sets of 3 squares followed by the counts of each digit:
    12321 12544 55225 [3, 5, 1, 2, 4]
    12321 33124 34225 [3, 5, 4, 2, 1]
    12321 44521 55225 [3, 5, 1, 2, 4]
    12321 52441 55225 [3, 5, 1, 2, 4]
    12544 34225 44521 [2, 4, 1, 5, 3]
    12544 34225 52441 [2, 4, 1, 5, 3]
    34225 44521 52441 [2, 4, 1, 5, 3]

In every case but one, the '3' is counted only once.  The odd man is 
12321 33124 34225 [3, 5, 4, 2, 1]
The three squares must be:  {12321, 33124, 34225}

--------------
squares = [i**2 for i in range(100,317)]

sqs = []
no = '06789'
for s in squares:
    good = True
    for c in str(s):
        if c in no:
            good = False
    if good:
        sqs.append(s)
print(sqs)

from itertools import combinations
target = [1,2,3,4,5]
for comb in combinations(sqs,3):
    score = []
    sview = list(str(comb[0])+str(comb[1])+str(comb[2]))
    view = [int(i) for i in sview]
    for i in range(1,6):
        if view.count(i) == i:
            continue
        score.append(view.count(i))
    if sorted(score) == target:
        print(int(''.join(sview[0:5])), int(''.join(sview[5:10])), int(''.join(sview[10:15])), score)

  Posted by Larry on 2023-08-02 10:24:54
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 (14)
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