Two women, Arlene and Cheryl, and two men, Burton and Donald, are musicians. They are a pianist, a violinist, a flutist, and a drummer, in some order. On a day they were seated around a square table:
- The person who sat across from Burton was the pianist.
- The person who sat across from Donald was not the flutist.
- The person who sat on Arlene's left was the violinist.
- The person who sat on Cheryl's left was not the drummer.
- The flutist and the drummer were married.
Who is the drummer?
: Each of the flutist and the drummer has precisely one spouse, of the opposite gender.
DECLARE SUB permute (a$)
nam$ = "abcd": nh$ = nam$
occ$ = "pvfd": oh$ = occ$
burt = INSTR(nam$, "b")
oppb = (burt + 2) MOD 4: IF oppb = 0 THEN oppb = 4
IF MID$(occ$, oppb, 1) = "p" THEN
don = INSTR(nam$, "d")
oppd = (don + 2) MOD 4: IF oppd = 0 THEN oppd = 4
IF MID$(occ$, oppd, 1) <> "f" THEN
arl = INSTR(nam$, "a")
oppa = (arl + 3) MOD 4: IF oppa = 0 THEN oppa = 4
IF MID$(occ$, oppa, 1) = "v" THEN
cher = INSTR(nam$, "c")
oppc = (cher + 3) MOD 4: IF oppc = 0 THEN oppc = 4
IF MID$(occ$, oppc, 1) <> "d" THEN
flute = INSTR(occ$, "f")
drum = INSTR(occ$, "d")
f$ = MID$(nam$, flute, 1)
d$ = MID$(nam$, drum, 1)
IF ABS(ASC(d$) - ASC(f$)) MOD 2 = 1 THEN
PRINT nam$, occ$
LOOP UNTIL occ$ = oh$
a$ = MID$(nam$, 2)
nam$ = LEFT$(nam$, 1) + a$
LOOP UNTIL nam$ = nh$
meaning that in order around the table are Arlene, Cheryl, Burton and Donald, who are respectively, pianist, drummer, flutist and violinist.
So the drummer is Cheryl.
Posted by Charlie
on 2012-11-23 20:49:55