The only possible lists are:
1, 36, 784, 9025
9, 16, 784, 3025
9, 81, 324, 7056
9, 81, 576, 2304
Only the last two share two squares (9 and 81), so they must be Alice's and Brian's, but we don't know which is which.
The second list shares a number with those two, and so can't be Carol's list.
So Carol's list must be the first one, and David's is the second.
OPEN "squarely.txt" FOR OUTPUT AS #2
DIM sq(100)
FOR i = 1 TO 99
sq(i) = i * i
NEXT
FOR a = 1 TO 96
s1$ = LTRIM$(STR$(sq(a)))
FOR b = a + 1 TO 97
s2$ = s1$ + LTRIM$(STR$(sq(b)))
FOR c = b + 1 TO 98
s3$ = s2$ + LTRIM$(STR$(sq(c)))
IF LEN(s3$) >= 6 AND LEN(s3$) <= 9 THEN
s4$ = s3$ + LTRIM$(STR$(sq(d)))
IF LEN(s4$) = 10 THEN
REDIM had(9): good = 1
FOR i = 1 TO 10
v = VAL(MID$(s4$, i, 1))
IF had(v) THEN good = 0: EXIT FOR
had(v) = 1
NEXT
IF good THEN
PRINT sq(a); sq(b); sq(c); sq(d)
PRINT #2, sq(a); sq(b); sq(c); sq(d)
END IF
END IF
NEXT
END IF
NEXT
NEXT
NEXT
Based on Enigma No. 1478, "Yours squarely", by Adrian Somerfield, New Scientist, 26 January 2008.
