DECLARE SUB build (wh!)
DATA 22,15,8,12,47,55
DATA 13,7,18,12,18,53
DATA 22,8,12,13,17,18
DATA 15,24,12,15,40,12
DATA 8,7,23,12,20,8
DATA 11,8,37,18,14,31
FOR r = 1 TO 6
FOR c = 1 TO 6
READ v(r, c)
NEXT
NEXT
OPEN "anothrsq.txt" FOR OUTPUT AS #2
DIM SHARED sqCt
FOR r = 1 TO 6
FOR c = 1 TO 6
gr(r, c) = v(r - 1, c) + v(r + 1, c) + v(r, c - 1) + v(r, c + 1)
sq = gr(r, c)
sr = INT(SQR(sq) + .5)
IF sr * sr = sq THEN
PRINT USING "###"; sq;
sqCt = sqCt + 1
sqLst(sqCt) = sq
ELSE
PRINT " . ";
END IF
NEXT
PRINT
NEXT
PRINT
DIM SHARED goodBase(sqCt, 30)
FOR i = 1 TO sqCt
PRINT sqLst(i)
j = 0
FOR b = 11 TO 99
good = 1
n = sqLst(i)
DO
d = n MOD b: n = n \ b
IF d > 9 THEN good = 0: EXIT DO
LOOP UNTIL n = 0
IF good THEN
PRINT b;
j = j + 1
goodBase(i, j) = b
goodBase(i, 0) = j
END IF
NEXT
PRINT : PRINT
NEXT
DIM SHARED baseUsed(sqCt), currTot, minTot
minTot = 99999
build 1
CLOSE
END
SUB build (wh)
FOR i = 1 TO goodBase(wh, 0)
good = 1
FOR j = 1 TO wh - 1
IF baseUsed(j) = goodBase(wh, i) THEN good = 0: EXIT FOR
NEXT
IF good THEN
baseUsed(wh) = goodBase(wh, i)
currTot = currTot + goodBase(wh, i)
IF wh = sqCt THEN
sr = INT(SQR(currTot) + .5)
IF sr * sr = currTot THEN
IF currTot <= minTot THEN
FOR j = 1 TO sqCt: PRINT #2, baseUsed(j); : NEXT
PRINT #2, , currTot
minTot = currTot
END IF
END IF
ELSE
build wh + 1
END IF
currTot = currTot - goodBase(wh, i)
END IF
NEXT
END SUB
finds that the second square's square numbers are as follows:
. . . . . 100
. . . . . .
36 . . . . .
. . . . 64 .
. . . . . .
16 . 49 . . .
and that the valid bases (i.e., using only digits 0 - 9) for the five squares are listed as:
100
11 12 13 14 16 19 20 23 24 25 31 32 33 46 47 48 49 50 91 92 93 94 95 96 97 98 99
36
11 12 14 15 16 17 18 27 28 29 30 31 32 33 34 35 36
64
11 12 14 15 16 19 20 21 28 29 30 31 32 55 56 57 58 59 60 61 62 63 64
16
11 12 13 14 15 16
49
11 12 14 15 16 20 21 22 23 24 40 41 42 43 44 45 46 47 48 49
and the lowest sum of valid bases for these numbers is 81, achievable by any of the following sets of bases (see the note at the bottom, showing the lowest maximum base used is 19):
for:
100 36 64 16 49
11 12 19 15 24 81
11 12 19 16 23 81
11 12 20 14 24 81
11 12 20 15 23 81
11 12 20 16 22 81
11 12 21 13 24 81
11 12 21 14 23 81
11 12 21 15 22 81
11 12 28 14 16 81
11 12 28 16 14 81
11 12 29 13 16 81
11 12 29 14 15 81
11 12 29 15 14 81
11 12 30 13 15 81
11 12 31 13 14 81
11 14 19 13 24 81
11 14 19 15 22 81
11 14 19 16 21 81
11 14 20 12 24 81
11 14 20 13 23 81
11 14 20 15 21 81
11 14 21 12 23 81
11 14 21 13 22 81
11 14 21 15 20 81
11 14 28 12 16 81
11 14 28 13 15 81
11 14 28 16 12 81
11 14 29 12 15 81
11 14 29 15 12 81
11 14 31 13 12 81
11 15 19 12 24 81
11 15 19 13 23 81
11 15 19 14 22 81
11 15 19 16 20 81
11 15 20 12 23 81
11 15 20 13 22 81
11 15 20 14 21 81
11 15 21 12 22 81
11 15 21 14 20 81
11 15 28 13 14 81
11 15 29 12 14 81
11 15 29 14 12 81
11 15 30 13 12 81
11 16 19 12 23 81
11 16 19 13 22 81
11 16 19 14 21 81
11 16 19 15 20 81
11 16 20 12 22 81
11 16 20 13 21 81
11 16 21 13 20 81
11 16 28 12 14 81
11 16 28 14 12 81
11 16 29 13 12 81
11 17 14 15 24 81
11 17 14 16 23 81
11 17 15 14 24 81
11 17 15 16 22 81
11 17 16 13 24 81
11 17 16 14 23 81
11 17 16 15 22 81
11 17 19 12 22 81
11 17 19 13 21 81
11 17 19 14 20 81
11 17 20 12 21 81
11 17 21 12 20 81
11 17 28 13 12 81
11 18 12 16 24 81
11 18 14 15 23 81
11 18 14 16 22 81
11 18 15 13 24 81
11 18 15 14 23 81
11 18 15 16 21 81
11 18 16 12 24 81
11 18 16 13 23 81
11 18 16 14 22 81
11 18 16 15 21 81
11 18 19 12 21 81
11 18 19 13 20 81
11 18 21 15 16 81
11 18 21 16 15 81
11 27 12 15 16 81
11 27 12 16 15 81
11 27 14 13 16 81
11 27 15 12 16 81
11 27 15 16 12 81
11 27 16 12 15 81
11 27 16 13 14 81
11 27 16 15 12 81
11 28 12 14 16 81
11 28 12 16 14 81
11 28 14 12 16 81
11 28 14 13 15 81
11 28 14 16 12 81
11 28 15 13 14 81
11 28 16 12 14 81
11 28 16 14 12 81
11 29 12 13 16 81
11 29 12 14 15 81
11 29 12 15 14 81
11 29 14 12 15 81
11 29 14 15 12 81
11 29 15 12 14 81
11 29 15 14 12 81
11 29 16 13 12 81
11 30 12 13 15 81
11 30 15 13 12 81
11 31 12 13 14 81
11 31 14 13 12 81
12 11 19 15 24 81
12 11 19 16 23 81
12 11 20 14 24 81
12 11 20 15 23 81
12 11 20 16 22 81
12 11 21 13 24 81
12 11 21 14 23 81
12 11 21 15 22 81
12 11 28 14 16 81
12 11 28 16 14 81
12 11 29 13 16 81
12 11 29 14 15 81
12 11 29 15 14 81
12 11 30 13 15 81
12 11 31 13 14 81
12 14 15 16 24 81
12 14 16 15 24 81
12 14 19 13 23 81
12 14 19 15 21 81
12 14 19 16 20 81
12 14 20 11 24 81
12 14 20 13 22 81
12 14 21 11 23 81
12 14 28 11 16 81
12 14 28 16 11 81
12 14 29 11 15 81
12 14 29 15 11 81
12 14 31 13 11 81
12 15 14 16 24 81
12 15 16 14 24 81
12 15 19 11 24 81
12 15 19 13 22 81
12 15 19 14 21 81
12 15 20 11 23 81
12 15 20 13 21 81
12 15 21 11 22 81
12 15 21 13 20 81
12 15 29 11 14 81
12 15 29 14 11 81
12 15 30 13 11 81
12 16 14 15 24 81
12 16 15 14 24 81
12 16 19 11 23 81
12 16 19 13 21 81
12 16 19 14 20 81
12 16 20 11 22 81
12 16 28 11 14 81
12 16 28 14 11 81
12 16 29 13 11 81
12 17 14 15 23 81
12 17 14 16 22 81
12 17 15 13 24 81
12 17 15 14 23 81
12 17 15 16 21 81
12 17 16 13 23 81
12 17 16 14 22 81
12 17 16 15 21 81
12 17 19 11 22 81
12 17 19 13 20 81
12 17 20 11 21 81
12 17 21 11 20 81
12 17 21 15 16 81
12 17 21 16 15 81
12 17 28 13 11 81
12 18 11 16 24 81
12 18 14 13 24 81
12 18 14 15 22 81
12 18 14 16 21 81
12 18 15 13 23 81
12 18 15 14 22 81
12 18 15 16 20 81
12 18 16 11 24 81
12 18 16 13 22 81
12 18 16 14 21 81
12 18 16 15 20 81
12 18 19 11 21 81
12 18 20 15 16 81
12 18 20 16 15 81
12 18 21 14 16 81
12 18 21 16 14 81
12 27 11 15 16 81
12 27 11 16 15 81
12 27 14 13 15 81
12 27 15 11 16 81
12 27 15 13 14 81
12 27 15 16 11 81
12 27 16 11 15 81
12 27 16 15 11 81
12 28 11 14 16 81
12 28 11 16 14 81
12 28 14 11 16 81
12 28 14 16 11 81
12 28 16 11 14 81
12 28 16 14 11 81
12 29 11 13 16 81
12 29 11 14 15 81
12 29 11 15 14 81
12 29 14 11 15 81
12 29 14 15 11 81
12 29 15 11 14 81
12 29 15 14 11 81
12 29 16 13 11 81
12 30 11 13 15 81
12 30 15 13 11 81
12 31 11 13 14 81
12 31 14 13 11 81
13 11 19 14 24 81
13 11 19 15 23 81
13 11 19 16 22 81
13 11 20 14 23 81
13 11 20 15 22 81
13 11 20 16 21 81
13 11 21 12 24 81
13 11 21 14 22 81
13 11 21 16 20 81
13 11 28 14 15 81
13 11 28 15 14 81
13 11 29 12 16 81
13 11 29 16 12 81
13 11 30 12 15 81
13 11 30 15 12 81
13 11 31 12 14 81
13 11 31 14 12 81
13 12 19 14 23 81
13 12 19 15 22 81
13 12 19 16 21 81
13 12 20 14 22 81
13 12 20 15 21 81
13 12 21 11 24 81
13 12 21 15 20 81
13 12 29 11 16 81
13 12 29 16 11 81
13 12 30 11 15 81
13 12 30 15 11 81
13 12 31 11 14 81
13 12 31 14 11 81
13 14 15 16 23 81
13 14 16 15 23 81
13 14 19 11 24 81
13 14 19 12 23 81
13 14 19 15 20 81
13 14 20 11 23 81
13 14 20 12 22 81
13 14 21 11 22 81
13 14 28 11 15 81
13 14 28 15 11 81
13 14 31 11 12 81
13 14 31 12 11 81
13 15 14 16 23 81
13 15 16 14 23 81
13 15 19 11 23 81
13 15 19 12 22 81
13 15 19 14 20 81
13 15 20 11 22 81
13 15 20 12 21 81
13 15 21 12 20 81
13 15 28 11 14 81
13 15 28 14 11 81
13 15 30 11 12 81
13 15 30 12 11 81
13 16 14 15 23 81
13 16 15 14 23 81
13 16 19 11 22 81
13 16 19 12 21 81
13 16 20 11 21 81
13 16 21 11 20 81
13 16 29 11 12 81
13 16 29 12 11 81
13 17 11 16 24 81
13 17 12 15 24 81
13 17 12 16 23 81
13 17 14 15 22 81
13 17 14 16 21 81
13 17 15 12 24 81
13 17 15 14 22 81
13 17 15 16 20 81
13 17 16 11 24 81
13 17 16 12 23 81
13 17 16 14 21 81
13 17 16 15 20 81
13 17 19 11 21 81
13 17 19 12 20 81
13 17 20 15 16 81
13 17 20 16 15 81
13 17 21 14 16 81
13 17 21 16 14 81
13 17 28 11 12 81
13 17 28 12 11 81
13 18 11 15 24 81
13 18 11 16 23 81
13 18 12 14 24 81
13 18 12 15 23 81
13 18 12 16 22 81
13 18 14 12 24 81
13 18 14 15 21 81
13 18 14 16 20 81
13 18 15 11 24 81
13 18 15 12 23 81
13 18 15 14 21 81
13 18 16 11 23 81
13 18 16 12 22 81
13 18 16 14 20 81
13 18 19 11 20 81
13 18 19 15 16 81
13 18 19 16 15 81
13 18 20 14 16 81
13 18 20 16 14 81
13 18 21 14 15 81
13 18 21 15 14 81
13 27 11 14 16 81
13 27 11 16 14 81
13 27 12 14 15 81
13 27 12 15 14 81
13 27 14 11 16 81
13 27 14 12 15 81
13 27 14 15 12 81
13 27 14 16 11 81
13 27 15 12 14 81
13 27 15 14 12 81
13 27 16 11 14 81
13 27 16 14 11 81
13 28 11 14 15 81
13 28 11 15 14 81
13 28 14 11 15 81
13 28 14 15 11 81
13 28 15 11 14 81
13 28 15 14 11 81
13 29 11 12 16 81
13 29 11 16 12 81
13 29 12 11 16 81
13 29 12 16 11 81
13 29 16 11 12 81
13 29 16 12 11 81
13 30 11 12 15 81
13 30 11 15 12 81
13 30 12 11 15 81
13 30 12 15 11 81
13 30 15 11 12 81
13 30 15 12 11 81
13 31 11 12 14 81
13 31 11 14 12 81
13 31 12 11 14 81
13 31 12 14 11 81
13 31 14 11 12 81
13 31 14 12 11 81
14 11 19 13 24 81
14 11 19 15 22 81
14 11 19 16 21 81
14 11 20 12 24 81
14 11 20 13 23 81
14 11 20 15 21 81
14 11 21 12 23 81
14 11 21 13 22 81
14 11 21 15 20 81
14 11 28 12 16 81
14 11 28 13 15 81
14 11 28 16 12 81
14 11 29 12 15 81
14 11 29 15 12 81
14 11 31 13 12 81
14 12 15 16 24 81
14 12 16 15 24 81
14 12 19 13 23 81
14 12 19 15 21 81
14 12 19 16 20 81
14 12 20 11 24 81
14 12 20 13 22 81
14 12 21 11 23 81
14 12 28 11 16 81
14 12 28 16 11 81
14 12 29 11 15 81
14 12 29 15 11 81
14 12 31 13 11 81
14 15 12 16 24 81
14 15 16 12 24 81
14 15 16 13 23 81
14 15 19 11 22 81
14 15 19 12 21 81
14 15 19 13 20 81
14 15 20 11 21 81
14 15 21 11 20 81
14 15 28 13 11 81
14 15 29 11 12 81
14 15 29 12 11 81
14 16 12 15 24 81
14 16 15 12 24 81
14 16 15 13 23 81
14 16 19 11 21 81
14 16 19 12 20 81
14 16 28 11 12 81
14 16 28 12 11 81
14 17 11 15 24 81
14 17 11 16 23 81
14 17 12 15 23 81
14 17 12 16 22 81
14 17 15 11 24 81
14 17 15 12 23 81
14 17 15 13 22 81
14 17 16 11 23 81
14 17 16 12 22 81
14 17 16 13 21 81
14 17 19 11 20 81
14 17 19 15 16 81
14 17 19 16 15 81
14 17 21 13 16 81
14 18 11 15 23 81
14 18 11 16 22 81
14 18 12 13 24 81
14 18 12 15 22 81
14 18 12 16 21 81
14 18 15 11 23 81
14 18 15 12 22 81
14 18 15 13 21 81
14 18 16 11 22 81
14 18 16 12 21 81
14 18 16 13 20 81
14 18 20 13 16 81
14 18 21 12 16 81
14 18 21 13 15 81
14 18 21 16 12 81
14 27 11 13 16 81
14 27 12 13 15 81
14 27 15 13 12 81
14 27 16 13 11 81
14 28 11 12 16 81
14 28 11 13 15 81
14 28 11 16 12 81
14 28 12 11 16 81
14 28 12 16 11 81
14 28 15 13 11 81
14 28 16 11 12 81
14 28 16 12 11 81
14 29 11 12 15 81
14 29 11 15 12 81
14 29 12 11 15 81
14 29 12 15 11 81
14 29 15 11 12 81
14 29 15 12 11 81
14 31 11 13 12 81
14 31 12 13 11 81
16 11 19 12 23 81
16 11 19 13 22 81
16 11 19 14 21 81
16 11 19 15 20 81
16 11 20 12 22 81
16 11 20 13 21 81
16 11 21 13 20 81
16 11 28 12 14 81
16 11 28 14 12 81
16 11 29 13 12 81
16 12 14 15 24 81
16 12 15 14 24 81
16 12 19 11 23 81
16 12 19 13 21 81
16 12 19 14 20 81
16 12 20 11 22 81
16 12 28 11 14 81
16 12 28 14 11 81
16 12 29 13 11 81
16 14 12 15 24 81
16 14 15 12 24 81
16 14 15 13 23 81
16 14 19 11 21 81
16 14 19 12 20 81
16 14 28 11 12 81
16 14 28 12 11 81
16 15 12 14 24 81
16 15 14 12 24 81
16 15 14 13 23 81
16 15 19 11 20 81
16 17 11 13 24 81
16 17 11 14 23 81
16 17 11 15 22 81
16 17 12 13 23 81
16 17 12 14 22 81
16 17 12 15 21 81
16 17 14 11 23 81
16 17 14 12 22 81
16 17 14 13 21 81
16 17 15 11 22 81
16 17 15 12 21 81
16 17 15 13 20 81
16 17 19 14 15 81
16 17 19 15 14 81
16 17 20 13 15 81
16 17 21 12 15 81
16 17 21 13 14 81
16 17 21 15 12 81
16 18 11 12 24 81
16 18 11 13 23 81
16 18 11 14 22 81
16 18 11 15 21 81
16 18 12 11 24 81
16 18 12 13 22 81
16 18 12 14 21 81
16 18 12 15 20 81
16 18 14 11 22 81
16 18 14 12 21 81
16 18 14 13 20 81
16 18 15 11 21 81
16 18 15 12 20 81
16 18 19 13 15 81
16 18 20 12 15 81
16 18 20 13 14 81
16 18 20 15 12 81
16 18 21 11 15 81
16 18 21 12 14 81
16 18 21 14 12 81
16 18 21 15 11 81
16 27 11 12 15 81
16 27 11 13 14 81
16 27 11 15 12 81
16 27 12 11 15 81
16 27 12 15 11 81
16 27 14 13 11 81
16 27 15 11 12 81
16 27 15 12 11 81
16 28 11 12 14 81
16 28 11 14 12 81
16 28 12 11 14 81
16 28 12 14 11 81
16 28 14 11 12 81
16 28 14 12 11 81
16 29 11 13 12 81
16 29 12 13 11 81
19 11 12 15 24 81
19 11 12 16 23 81
19 11 14 13 24 81
19 11 14 15 22 81
19 11 14 16 21 81
19 11 15 12 24 81
19 11 15 13 23 81
19 11 15 14 22 81
19 11 15 16 20 81
19 11 16 12 23 81
19 11 16 13 22 81
19 11 16 14 21 81
19 11 16 15 20 81
19 11 20 15 16 81
19 11 20 16 15 81
19 11 21 14 16 81
19 11 21 16 14 81
19 12 11 15 24 81
19 12 11 16 23 81
19 12 14 13 23 81
19 12 14 15 21 81
19 12 14 16 20 81
19 12 15 11 24 81
19 12 15 13 22 81
19 12 15 14 21 81
19 12 16 11 23 81
19 12 16 13 21 81
19 12 16 14 20 81
19 12 20 14 16 81
19 12 20 16 14 81
19 12 21 13 16 81
19 12 21 14 15 81
19 12 21 15 14 81
19 14 11 13 24 81
19 14 11 15 22 81
19 14 11 16 21 81
19 14 12 13 23 81
19 14 12 15 21 81
19 14 12 16 20 81
19 14 15 11 22 81
19 14 15 12 21 81
19 14 15 13 20  
|
Posted by Charlie
on 2010-07-06 23:51:33 |