Four women -- April, Bella, Cara, and Denise -- and three men -- Edwin, Frank, and Gary -- play bridge, a card game for four players.
- The men and women consist of three married couples and a widow.
- The members of each married couple are never partners in a bridge game.
- No more than one married couple ever plays in the same bridge game.
One night they played four bridge games in which the partners were as follows:
Partners Partners
April and Edwin versus Bella and Frank
April and Gary versus Denise and Frank
Bella and Cara versus Frank and Gary
Cara and Edwin versus Denise and Gary
Who is the widow?
DECLARE SUB permute (a$)
CLS
PRINT "EFGw"
DATA aebf,agdf,bcfg,cedg
a$ = "abcd": h$ = a$
husb$ = "efgw"
' for sequence of husbands: e,f,g,widow
DO
RESTORE
good = 1
FOR game = 1 TO 4
READ lineup$
ix = INSTR(a$, MID$(lineup$, 1, 1))
ixp = INSTR(husb$, MID$(lineup$, 2, 1))
IF ix = ixp THEN good = 0: EXIT FOR
ix2 = INSTR(a$, MID$(lineup$, 3, 1))
ixp2 = INSTR(husb$, MID$(lineup$, 4, 1))
IF ix2 = ixp2 THEN good = 0: EXIT FOR
IF good THEN
men$ = "": women$ = ""
FOR i = 1 TO 4
IF MID$(lineup$, i, 1) <= "d" THEN women$ = women$ + MID$(lineup$, i, 1)
IF MID$(lineup$, i, 1) >= "e" THEN men$ = men$ + MID$(lineup$, i, 1)
NEXT
IF LEN(women$) = 2 THEN
hct = 0
w = INSTR(a$, LEFT$(women$, 1)): hu$ = MID$(husb$, w, 1)
IF INSTR(men$, hu$) > 0 THEN hct = hct + 1
w = INSTR(a$, RIGHT$(women$, 1)): hu$ = MID$(husb$, w, 1)
IF INSTR(men$, hu$) > 0 THEN hct = hct + 1
IF hct = 2 THEN good = 0
END IF
END IF
IF good = 0 THEN EXIT FOR
NEXT game
IF good THEN PRINT a$
permute a$
LOOP UNTIL a$ = h$
finds
EFGw
dabc
where the top row shows the husband's initials (and a widow position), and the wive's initials appear below each one's husband's, or state of widowhood.
Cara is the widow.
|
Posted by Charlie
on 2013-12-12 17:51:21 |