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

Home > Numbers
Five Squares (Posted on 2007-04-18) Difficulty: 3 of 5
This array of base 10 digits, read from left to right and top-down, contains 4 square numbers. The fifth numeral is as close as possible to another square.

     a  b  c
     d  e  f

Identify the array.

See The Solution Submitted by brianjn    
Rating: 3.7500 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 7
8  4  3
1  9  6     one number off by 2 from a square

is the best found by

CLS
FOR a = 0 TO 9
 taken(a) = 1
FOR b = 0 TO 9
 IF taken(b) = 0 THEN
  taken(b) = 1
FOR c = 0 TO 9
 IF taken(c) = 0 THEN
  taken(c) = 1
  abc = a * 100 + b * 10 + c
FOR d = 0 TO 9
 IF taken(d) = 0 THEN
  taken(d) = 1
  ad = 10 * a + d
FOR e = 0 TO 9
 IF taken(e) = 0 THEN
  taken(e) = 1
  be = 10 * b + e
FOR f = 0 TO 9
 IF taken(f) = 0 THEN
  taken(f) = 1
  cf = 10 * c + f
  defV = 100 * d + 10 * e + f

  offby = 0: good = 1
  tst = abc: GOSUB tstsqr
  IF good THEN
    tst = defV: GOSUB tstsqr
  IF good THEN
    tst = ad: GOSUB tstsqr
  IF good THEN
    tst = be: GOSUB tstsqr
  IF good THEN
    tst = cf: GOSUB tstsqr
  IF good THEN
    PRINT a; b; c: PRINT d; e; f, offby
    PRINT
  END IF
  END IF
  END IF
  END IF
  END IF

  taken(f) = 0
 END IF
NEXT
  taken(e) = 0
 END IF
NEXT
  taken(d) = 0
 END IF
NEXT
  taken(c) = 0
 END IF
NEXT
  taken(b) = 0
 END IF
NEXT
  taken(a) = 0
NEXT
END

tstsqr:
  sr1 = INT(SQR(tst) + .5)
  IF sr1 * sr1 <> tst THEN
   IF offby = 0 THEN
     IF sr1 * sr1 < tst THEN sr2 = sr1 + 1:  ELSE sr2 = sr1 - 1
     d1 = ABS(tst - sr1 * sr1): d2 = ABS(tst - sr2 * sr2)
     IF d1 < d2 THEN offby = d1:  ELSE offby = d2
   ELSE
     good = 0
   END IF
  END IF
RETURN

The others found were:

0  3  4
1  6  9       2
0  3  8
9  6  1       2
0  4  3
1  9  6       6
3  2  4
6  5  9       17
4  3  0
9  6  1       11
4  3  8
9  6  1       3
8  0  3
1  9  6       19
8  3  0
1  6  9       11
8  3  4
1  6  9       7

where the amount off from a perfect square was larger than 2 and/or there were leading zeros and/or the degenerate square 1 was used.


  Posted by Charlie on 2007-04-18 11:32:07
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 (3)
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