A
+---+---+
| | |
J +---+---+ B
| | |
| | |
| | |
I +---+---+ C
| | | D
| | +---+----+
| | | |
H +---+-------+----+ E
| | | |
+---+-------+----+
G F
Mr. and Mrs. Larchmont invited four married couples to a dinner party. For the party, chairs A to J were placed around an L-shaped table as shown above.
- Every woman sat next to her husband.
- A is next to B, B is next to C, C is next to D, D is next to E, E is next to F, F is next to G, G is next to I and, I is next to J.
- Every woman sat directly across from a man. (Chairs at the ends of a dashed line denotes "directly across" from each other.
- Mrs. Larchmont sat to the right of Mr. larchmont.
- Mrs. Larchmont was the only woman who did not sit next to a woman.
In which of the chairs from A to J inclusively did Mrs. Larchmont sit?
Notes:
(i) A person sitting next to another person implies that the other person is sitting next to the said person. For example, A is next to B implies that B is next to A and vice versa.
(ii) "To the right of" is defined as the one they see when they turn their head to their own right. For example, F to the right of G.
DECLARE SUB permute (a$)
CLS
OPEN "chair cue.txt" FOR OUTPUT AS #2
a$ = "LlWwXxYyZz": h$ = a$
DO
tst$ = LCASE$(a$) + LCASE$(a$)
good = 1
IF INSTR(tst$, "ll") = 0 THEN good = 0
IF INSTR(tst$, "xx") = 0 THEN good = 0
IF INSTR(tst$, "yy") = 0 THEN good = 0
IF INSTR(tst$, "zz") = 0 THEN good = 0
IF INSTR(tst$, "ww") = 0 THEN good = 0
IF good THEN
s$ = a$
FOR i = 1 TO LEN(s$)
IF MID$(s$, i, 1) = UCASE$(MID$(s$, i, 1)) THEN
MID$(s$, i, 1) = "m"
ELSE
MID$(s$, i, 1) = "w"
END IF
NEXT
IF MID$(s$, 1, 1) = MID$(s$, 7, 1) THEN good = 0
IF MID$(s$, 2, 1) = MID$(s$, 10, 1) THEN good = 0
IF MID$(s$, 3, 1) = MID$(s$, 9, 1) THEN good = 0
IF MID$(s$, 4, 1) = MID$(s$, 6, 1) THEN good = 0
IF MID$(s$, 5, 1) = MID$(s$, 8, 1) THEN good = 0
IF good THEN
s$ = s$ + LEFT$(s$, 2)
ct = 0: ix = 0
DO
ix = INSTR(ix + 1, s$, "mwm")
IF ix THEN ct = ct + 1: saveloc = ix
LOOP UNTIL ix = 0
IF ct <> 1 THEN good = 0
psn = saveloc + 1: IF psn > 12 THEN psn = psn - 12
IF MID$(a$, psn, 1) <> "l" THEN good = 0
s$ = a$ + LEFT$(a$, 1)
IF INSTR(s$, "lL") = 0 THEN good = 0
IF good THEN PRINT a$: PRINT #2, a$
END IF
END IF
permute a$
LOOP UNTIL a$ = h$
finds
LWwxXYyzZl
LWwxXZzyYl
LWwyYXxzZl
LWwyYZzxXl
LWwzZXxyYl
LWwzZYyxXl
LXxwWYyzZl
LXxwWZzyYl
LXxyYWwzZl
LXxyYZzwWl
LXxzZWwyYl
LXxzZYywWl
LYywWXxzZl
LYywWZzxXl
LYyxXWwzZl
LYyxXZzwWl
LYyzZWwxXl
LYyzZXxwWl
LZzwWXxyYl
LZzwWYyxXl
LZzxXWwyYl
LZzxXYywWl
LZzyYWwxXl
LZzyYXxwWl
where capital letters refer to men, lower case to women and the sequence is positions A through J.
Mrs. Larchmont was in J in all cases, to the right of Mr. Larchmont in seat A. Only the letter identities in the "different" solutions varied; the gender locations and the coupling remain the same in what is basically one solution.
|
Posted by Charlie
on 2014-03-07 12:50:56 |