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

Home > Just Math
Arrange the Digits (Posted on 2013-06-28) Difficulty: 3 of 5
Arrange the digits from one to nine in a 3x3 square in such a way that each of the three-digit numbers reading across, and the three-digit number on the diagonal from top left to bottom right, are all perfect squares.

See The Solution Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer method Comment 2 of 2 |

CLS
min = 10: max = SQR(999)
FOR b1 = min TO max
  s1 = b1 * b1
  d11 = s1 \ 100: d12 = (s1 \ 10) MOD 10: d13 = s1 MOD 10
  IF d11 <> d12 AND d11 <> d13 AND d12 <> d13 THEN
    used(d11) = 1: used(d12) = 1: used(d13) = 1
    FOR b2 = min TO max
      s2 = b2 * b2
      d21 = s2 \ 100: d22 = (s2 \ 10) MOD 10: d23 = s2 MOD 10
      IF d21 <> d22 AND d21 <> d23 AND d22 <> d23 THEN
        IF used(d21) = 0 AND used(d22) = 0 AND used(d23) = 0 THEN
          used(d21) = 1: used(d22) = 1: used(d23) = 1
          FOR b3 = min TO max
            s3 = b3 * b3
            d31 = s3 \ 100: d32 = (s3 \ 10) MOD 10: d33 = s3 MOD 10
            IF d31 <> d32 AND d31 <> d33 AND d32 <> d33 THEN
              IF used(d31) = 0 AND used(d32) = 0 AND used(d33) = 0 THEN

              s4 = 100 * d11 + 10 * d22 + d33
              sr = INT(SQR(s4) + .5)
              IF sr * sr = s4 THEN
                 PRINT s1
                 PRINT s2
                 PRINT s3
                 PRINT
              END IF
              END IF
            END IF
          NEXT b3
          used(d21) = 0: used(d22) = 0: used(d23) = 0
        END IF
      END IF
    NEXT b2
    used(d11) = 0: used(d12) = 0: used(d13) = 0
  END IF
NEXT

361
529
784


  Posted by Charlie on 2013-06-28 12:47:53
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 (8)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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