DECLARE SUB permute (a$)
DECLARE FUNCTION matchCt! (a$, b$)
name1$ = "iamp": name2$ = "necd": occ$ = "wgcb"
hName1$ = "iamp": hName2$ = "necd": hOcc$ = "wgcb"
DATA Isaac,Albert,Marie,Paul
DATA Newtune,Eyeline,Curious,Darling
DATA welder,gardener,cleaner,bricklayer
FOR i = 1 TO 4: READ n1$(i): NEXT
FOR i = 1 TO 4: READ n2$(i): NEXT
FOR i = 1 TO 4: READ oc$(i): NEXT
PRINT
DO
IF matchCt(name1$, hName1$) = 1 THEN
DO
IF matchCt(name2$, hName2$) = 1 THEN
DO
IF matchCt(occ$, hOcc$) = 1 THEN
good = 1
ix1 = INSTR(name1$, "a"): ix2 = INSTR(occ$, "b")
IF ix2 <> ix1 + 2 THEN good = 0
ix1 = INSTR(name1$, "p"): ix2 = INSTR(name2$, "d")
IF ix2 <> ix1 + 1 THEN good = 0
ix1 = INSTR(name2$, "c"): ix2 = INSTR(occ$, "w")
IF ix2 <> ix1 - 2 THEN good = 0
IF good THEN
FOR place = 1 TO 4
PRINT place;
PRINT n1$(INSTR(hName1$, MID$(name1$, place, 1))); " ";
PRINT TAB(12); n2$(INSTR(hName2$, MID$(name2$, place, 1))); " ";
PRINT TAB(22); oc$(INSTR(hOcc$, MID$(occ$, place, 1))); " "
NEXT
END IF
END IF
permute occ$
LOOP UNTIL occ$ = hOcc$
END IF
permute name2$
LOOP UNTIL name2$ = hName2$
END IF
permute name1$
LOOP UNTIL name1$ = hName1$
FUNCTION matchCt (a$, b$)
ct = 0
FOR i = 1 TO LEN(a$)
IF MID$(a$, i, 1) = MID$(b$, i, 1) THEN ct = ct + 1
NEXT
matchCt = ct
END FUNCTION