In the following layout, each letter is to be replaced by a decimal digit. As there are more than ten letters, there's obviously repetition of digits.
A B
C D E F
G H I J
K L
The digits can be considered as forming eight numbers, read left to right and top to bottom. Four have four digits each and four have two digits each.
Seven of these eight numbers are perfect squares. Only AB is not.
What are the digits to replace the letters?
using Qbasic I searched all possible combinations and find the following single solution
71
2304
5929
64
code follows:
CLS 0
FOR a = 1 TO 9
FOR b = 1 TO 9
v = SQR(10 * a + b)
IF INT(v) <> v THEN
FOR s1 = 4 TO 9
sq1 = s1 ^ 2
g = sq1 MOD 10
c = (sq1 - g) / 10
FOR s2 = 4 TO 9
sq2 = s2 ^ 2
j = sq2 MOD 10
f = (sq2 - j) / 10
FOR s3 = 4 TO 9
sq3 = s3 ^ 2
l = sq3 MOD 10
k = (sq3 - l) / 10
FOR d = 0 TO 9
FOR e = 0 TO 9
v = SQR(f + 10 * e + 100 * d + 1000 * c)
IF INT(v) = v THEN
FOR h = 0 TO 9
v = SQR(k + 10 * h + 100 * d + 1000 * a)
IF INT(v) = v THEN
FOR i = 0 TO 9
v = SQR(l + 10 * i + 100 * e + 1000 * b)
v2 = SQR(j + 10 * i + 100 * h + 1000 * g)
IF INT(v) = v AND INT(v2) = v2 THEN
PRINT " " + STR$(a) + " " + STR$(b)
PRINT STR$(c) + " " + STR$(d) + " "; STR$(e) + " " + STR$(f)
PRINT STR$(g) + " " + STR$(h) + " " + STR$(i) + " "; STR$(j)
PRINT " " + STR$(k) + " " + STR$(l)
END IF
NEXT i
END IF
NEXT h
END IF
NEXT e
NEXT d
NEXT s3
NEXT s2
NEXT s1
END IF
NEXT b
NEXT a
|
Posted by Daniel
on 2009-09-06 23:03:43 |