Amelia, Beulah, Carrie, Dennis and Elwood attended a supper party with
their spouses at Loverly's Restaurant. Chairs for the five couples were
arranged around an L-shaped table as shown in the diagram below.
a
+---------+
| |
| |
j| |b
| |
| |
| |
i| |c
| |
| | d
| +---------+
h| |
| |e
| |
+-------------------+
g f
At the table:
- Amelia's husband sat next to Dennis' wife.
- Beulah's husband was the only man who sat alone at one side of the
table.
- Carrie's husband was the only man who sat between two women.
- No woman sat between two women.
- Each man sat opposite his wife.
- Elwood's wife sat on the Professor's right.
Who was the Professor?
Notes:
(i) "Between two women" means to the left of one woman and to the right
of another woman, around the perimeter of the table.
(ii) Similarly "sat next to" means either immediately to the right or, immediately to the left of a given seat around the perimeter of the table. For example, chair-e and chair-f are next to each other.
DECLARE SUB permute (a$)
CLS
OPEN "profper3.txt" FOR OUTPUT AS #2
a$ = "AaBbCcDdEe": h$ = a$
' abcdefghij
DO
IF LCASE$(MID$(a$, 1, 1)) = LCASE$(MID$(a$, 7, 1)) THEN
IF LCASE$(MID$(a$, 2, 1)) = LCASE$(MID$(a$, 10, 1)) THEN
IF LCASE$(MID$(a$, 3, 1)) = LCASE$(MID$(a$, 9, 1)) THEN
IF LCASE$(MID$(a$, 4, 1)) = LCASE$(MID$(a$, 6, 1)) THEN
IF LCASE$(MID$(a$, 5, 1)) = LCASE$(MID$(a$, 8, 1)) THEN
dbl$ = a$ + a$
AmHus$ = "A"
IF INSTR(dbl$, AmHus$ + "d") > 0 OR INSTR(dbl$, "d" + AmHus$) > 0 THEN
BeHus$ = "B"
ix = INSTR(a$, BeHus$)
IF ix = 1 OR ix = 4 OR ix = 5 THEN
CaHus$ = "C"
ix = INSTR(2, dbl$, CaHus$)
IF MID$(dbl$, ix - 1, 1) + MID$(dbl$, ix + 1, 1) = LCASE$(MID$(dbl$, ix - 1, 1) + MID$(dbl$, ix + 1, 1)) THEN
mw$ = ""
FOR i = 1 TO LEN(dbl$)
IF UCASE$(MID$(dbl$, i, 1)) = MID$(dbl$, i, 1) THEN mw$ = mw$ + "m": ELSE mw$ = mw$ + "w"
NEXT
IF INSTR(2, mw$, "wmw") = ix - 1 AND (INSTR(ix, mw$, "wmw") = 0 OR INSTR(ix, mw$, "wmw") > 19 + ix) THEN
IF INSTR(mw$, "www") = 0 THEN
ElW = INSTR(dbl$, "e")
PRINT a$
PRINT MID$(dbl$, ElW + 1, 1)
PRINT
PRINT #2, a$
PRINT #2, hus$
PRINT #2, MID$(dbl$, ElW + 1, 1)
PRINT #2,
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
permute a$
LOOP UNTIL a$ = h$
CLOSE
finds
ecDBabEAdC
c
Interpreted as follows:
position person
a Elwood's wife
b Carrie
c Dennis
d Beulah's husband
e Amelia
f Beulah
g Elwood
h Amelia's husband
i Dennis's wife
j Carrie's husband
(in ecDBabEAdC, lower case is for the female partner and upper case for the male)
Carrie (c) is the professor.
Edited on April 25, 2013, 9:44 pm
|
Posted by Charlie
on 2013-04-25 21:43:36 |