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

Home > Numbers
Square of Squares (Posted on 2009-08-31) Difficulty: 3 of 5
Four 4-digit perfect squares are arranged one above the other, in ascending order. No two digits within any one of these squares is the same. If you sum the digits of each of these four squares, each result is the same sum. Also, the sum of the digits of each column formed by placing these digits above one another is the same. There may or may not be repeated digits within a column.

What are the 4-digit squares?

  Submitted by Charlie    
Rating: 5.0000 (1 votes)
Solution: (Hide)
The only 4-digit perfect squares without duplicate digits, together with the sums of their digits, are:

1024  7
2401  7
2304  9
2601  9
3025  10
5041  10
2704  13
3721  13
6241  13
3481  16
9025  16
1089  18
1296  18
1764  18
2916  18
3249  18
4356  18
4761  18
5184  18
6084  18
7056  18
9216  18
9801  18
1369  19
1936  19
2809  19
4096  19
5329  19
6724  19
7921  19
9604  19
1849  22
5476  22
7396  25
7569  27
8649  27
Only the digital sums 18 and 19 have at least 4 representatives, and among those, only the following has the same digital sum for each column when arranged as columns:

1764
3249
5184
9801

The final version of the program is shown, after the determination of 18 and 19 was made using only the first part:

DECLARE FUNCTION sod# (x#)
DEFDBL A-Z
DIM sq(100)
DIM sd(100)
st = -INT(-SQR(1000))
fin = INT(SQR(10000))
FOR n = st TO fin
  ns = n * n
  sum = sod(ns)
  IF sum > 0 THEN
    noSq = noSq + 1
    sq(noSq) = ns
    sd(noSq) = sum
  END IF
NEXT
DO
 done = 1
 FOR i = 1 TO noSq - 1
   IF sd(i) > sd(i + 1) THEN
     SWAP sd(i), sd(i + 1)
     SWAP sq(i), sq(i + 1)
     done = 0
   END IF
 NEXT
LOOP UNTIL done
FOR i = 1 TO noSq
  PRINT sq(i); sd(i)
  IF sd(i) = 18 AND first18 = 0 THEN first18 = i
  IF sd(i) > 18 AND last18 = 0 THEN last18 = i - 1
  IF sd(i) = 19 AND first19 = 0 THEN first19 = i
  IF sd(i) > 19 AND last19 = 0 THEN last19 = i - 1
NEXT
FOR a = first18 TO last18 - 3
  FOR b = a + 1 TO last18 - 2
   FOR c = b + 1 TO last18 - 1
    FOR d = c + 1 TO last18
     t1 = 0: t2 = 0: t3 = 0: t4 = 0
     n(1) = sq(a)
     n(2) = sq(b)
     n(3) = sq(c)
     n(4) = sq(d)
     FOR i = 1 TO 4
       t1 = t1 + n(i) \ 1000
       t2 = t2 + (n(i) \ 100) MOD 10
       t3 = t3 + (n(i) \ 10) MOD 10
       t4 = t4 + (n(i)) MOD 10
     NEXT
     IF t1 = t2 AND t2 = t3 AND t3 = t4 THEN
        PRINT n(1)
        PRINT n(2)
        PRINT n(3)
        PRINT n(4)
     END IF
    NEXT
   NEXT
  NEXT
NEXT
FOR a = first19 TO last19 - 3
  FOR b = a + 1 TO last19 - 2
   FOR c = b + 1 TO last19 - 1
    FOR d = c + 1 TO last19
     t1 = 0: t2 = 0: t3 = 0: t4 = 0
     n(1) = sq(a)
     n(2) = sq(b)
     n(3) = sq(c)
     n(4) = sq(d)
     FOR i = 1 TO 4
       t1 = t1 + n(i) \ 1000
       t2 = t2 + (n(i) \ 100) MOD 10
       t3 = t3 + (n(i) \ 10) MOD 10
       t4 = t4 + (n(i)) MOD 10
     NEXT
     IF t1 = t2 AND t2 = t3 AND t3 = t4 THEN
        PRINT n(1)
        PRINT n(2)
        PRINT n(3)
        PRINT n(4)
     END IF
    NEXT
   NEXT
  NEXT
NEXT

FUNCTION sod (x)
 s$ = LTRIM$(STR$(x))
 t = 0
 FOR i = 1 TO LEN(s$)
  IF INSTR(i + 1, s$, MID$(s$, i, 1)) THEN sod = 0: EXIT FUNCTION
  t = t + VAL(MID$(s$, i, 1))
 NEXT
 sod = t
END FUNCTION

From Enigma No. 1553, "Squares from squares", by Susan Denham, New Scientist, 11 July 2009, page 26.

Comments: ( You must be logged in to post comments.)
  Subject Author Date
Puzzle Thoughts K Sengupta2023-06-21 09:34:29
Interpretationed bottemiller2009-09-01 12:14:43
SolutionComputer solution with Spreadsheet layout.brianjn2009-08-31 21:47:29
solutioned bottemiller2009-08-31 15:09:55
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 (17)
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