Five couples went for a dance together. The names and surnames of neither boys nor girls started with the same letter. The list of names & surnames of boys and girls are given below.
Boys
Names – Arnold, Brad, Chris, Dennis, Elvis
Surnames – Aniston, Baker, Campbell, Davis, Edwards
Girls
Names – Angelina, Betty, Catherine, Diana, Elizabeth
Surnames – Austin, Burton, Carrey, Dean, Everts
The following things are known
Clue 1 Brad Aniston is neither going around with Ms Burton nor Catherine
Clue 2 Angelina Dean is neither going around with Mr Baker nor Chris
Clue 3 There are "two boys" whose name and their fiancée's surname start with the same letter. One is Chris, but the other is neither Arnold nor Mr. Baker.
Clue 4 There are two girls (who are not paired with either of the "two boys" referred in clue (3)) whose name and their fiancé's surname start with the same letter. One of them is Angelina but the other is neither Catherine nor Ms Everts.
Who is Elizabeth's Partner?
In the following bs$ is the string of first letters of the boys' surnames, gn$ of the first letters of the girls' first names and gs$, of the girls' surnames. The order of each is their correspondence to letters a  e of the boys' first names to which they correspond.
DECLARE SUB permute (a$)
CLS
bs$ = "abcde": hbs$ = bs$
DO
IF MID$(bs$, 2, 1) <> "a" THEN GOTO not1
baker = INSTR(bs$, "b")
IF baker = 1 OR baker = 3 THEN GOTO not1
FOR i = 1 TO 5
IF MID$(bs$, i, 1) = MID$("abcde", i, 1) THEN GOTO not1
NEXT i
gn$ = "abcde": hgn$ = gn$
DO
IF MID$(gn$, 2, 1) = "c" THEN GOTO not2
angelina = INSTR(gn$, "a")
IF MID$(bs$, angelina, 1) <> "a" THEN GOTO not2
catherine = INSTR(gn$, "c")
IF MID$(bs$, catherine, 1) = "c" THEN GOTO not2
matches = 0
FOR i = 1 TO 5
IF MID$(gn$, i, 1) = MID$(bs$, i, 1) THEN matches = matches + 1
NEXT
IF matches <> 2 THEN GOTO not2
gs$ = "abcde": hgs$ = gs$
DO
IF MID$(gs$, 3, 1) <> "c" THEN GOTO not3
IF MID$(gs$, 1, 1) = "a" THEN GOTO not3
IF MID$(gs$, 2, 1) = "b" THEN GOTO not3
IF MID$(gs$, angelina, 1) <> "d" THEN GOTO not3
IF MID$(gs$, baker, 1) = MID$("abcde", baker, 1) THEN GOTO not3
FOR i = 1 TO 5
IF MID$(gs$, i, 1) = MID$(gn$, i, 1) THEN GOTO not3
NEXT i
everts = INSTR(gs$, "e")
burton = INSTR(gs$, "b")
IF catherine = everts OR catherine = burton THEN GOTO not3
IF MID$(bs$, everts, 1) = MID$(gn$, everts, 1) THEN GOTO not3
matches = 0
FOR i = 1 TO 5
IF MID$(gs$, i, 1) = MID$("abcde", i, 1) THEN
matches = matches + 1
IF MID$(bs$, i, 1) = MID$(gn$, i, 1) THEN GOTO not3
END IF
NEXT
IF matches <> 2 THEN GOTO not3
ct = ct + 1
PRINT bs$: PRINT gn$: PRINT gs$: PRINT ct
not3:
permute gs$
LOOP UNTIL gs$ = hgs$
not2:
permute gn$
LOOP UNTIL gn$ = hgn$
not1:
permute bs$
LOOP UNTIL bs$ = hbs$
The permute subroutine is elsewhere on this site.
The result is:
eadbc
eabcd
bdcae
indicating Elizabeth Burton is with Arnold Edwards.
Also, Angelina Dean is with Brad Aniston,
Betty Carrey is with Chris Davis
Catherine Austin is with Dennis Baker
Diana Everts is with Elvis Campbell

Posted by Charlie
on 20060404 16:25:37 