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

 Five Squares (Posted on 2007-04-18)
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.6667 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 1 of 7
`8  4  31  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
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  41  6  9       2`
`0  3  89  6  1       2`
`0  4  31  9  6       6`
`3  2  46  5  9       17`
`4  3  09  6  1       11`
`4  3  89  6  1       3`
`8  0  31  9  6       19`
`8  3  01  6  9       11`
`8  3  41  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

 Search: Search body:
Forums (0)