MaVeriCK BuSTLe PiQUe GOlFer JiNX WRap brAZEn HolIDaY
MaVeriCK SuBTLe PiQUe GOlFer JiNX WRap brAZEn HolIDaY
DECLARE SUB place (psn!)
DATA -a-eri--,-u---e,-i--e,--l-er
DATA -i--,--ap,br---n,-ol--a-
CLS
DIM SHARED seq$(8), src$(8, 520), tot(8), used(26), h$(8)
FOR i = 1 TO 8
READ seq$(i)
PRINT seq$(i); " ";
NEXT
PRINT
FOR i = 1 TO 8
temp$ = seq$(i)
l = LEN(temp$)
w$ = SPACE$(l)
OPEN "\words\words" + LTRIM$(STR$(l)) + ".txt" FOR BINARY AS #1
DO
GET #1, , w$
IF EOF(1) THEN EXIT DO
good = 1
FOR j = 1 TO l
IF MID$(temp$, j, 1) <> "-" AND MID$(temp$, j, 1) <> MID$(w$, j, 1) THEN
good = 0: EXIT FOR
END IF
NEXT
IF good THEN
PRINT w$: tot(i) = tot(i) + 1
src$(i, tot(i)) = w$
END IF
LOOP
CLOSE 1
NEXT
PRINT
FOR i = 1 TO 8
PRINT tot(i);
NEXT
PRINT
place 1
PRINT
END
SUB place (psn)
FOR i = 1 TO tot(psn)
IF psn = 1 THEN PRINT i, tot(psn)
good = 1
REDIM temp(26)
FOR j = 1 TO LEN(seq$(psn))
IF MID$(seq$(psn), j, 1) = "-" THEN
ix = INSTR("abcdefghijklmnopqrstuvwxyz", MID$(src$(psn, i), j, 1))
IF used(ix) OR temp(ix) THEN good = 0: EXIT FOR
temp(ix) = 1
END IF
NEXT
IF good THEN
FOR j = 1 TO LEN(seq$(psn))
IF MID$(seq$(psn), j, 1) = "-" THEN
ix = INSTR("abcdefghijklmnopqrstuvwxyz", MID$(src$(psn, i), j, 1))
used(ix) = 1
END IF
NEXT j
h$(psn) = src$(psn, i)
IF psn = 8 THEN
PRINT
FOR j = 1 TO 8
FOR k = 1 TO LEN(src$(j, i))
IF MID$(seq$(j), k, 1) = "-" THEN
PRINT UCASE$(MID$(h$(j), k, 1));
ELSE
PRINT MID$(h$(j), k, 1);
END IF
NEXT k
PRINT " ";
NEXT
PRINT
ELSE
place psn + 1
END IF
FOR j = 1 TO LEN(seq$(psn))
IF MID$(seq$(psn), j, 1) = "-" THEN
ix = INSTR("abcdefghijklmnopqrstuvwxyz", MID$(src$(psn, i), j, 1))
used(ix) = 0
END IF
NEXT j
END IF
NEXT
END SUB
From Giant Book of Mensa Mind Challenges, edited by Todd Johnson, Section 3: "Nearly Impossible Brain Bafflers", page 200.
|