+--+--+--+--+
|1 |2 |3 |4 |
+--+--+--+--+--+--+
|5 | |6 |
+--+--+--+--+--+--+
|7 |8 |9 |10|
+--+--+--+--+
- A sat opposite G who was sitting next to C.
- C sat opposite F.
- D sat between F and H, but not in seat 8 or 9.
- E sat between G and A and opposite J.
- I sat between B and C but not in seat 9.
- The host sat in seat 5.
Who was the host?
DECLARE FUNCTION opp! (x$, y$)
DECLARE SUB permute (a$)
CLS
DIM SHARED a$
a$ = "abcdefghij": h$ = a$
label$ = "12346x9875"
DO
s$ = a$ + a$
IF opp("a", "g") THEN
IF INSTR(s$, "gc") OR INSTR(s$, "cg") THEN
IF opp("c", "f") THEN
IF INSTR(s$, "fdh") OR INSTR(s$, "hdf") THEN
IF INSTR(a$, "d") <> 8 AND INSTR(a$, "d") <> 7 THEN
IF opp("e", "j") THEN
IF INSTR(s$, "gea") OR INSTR(s$, "aeg") THEN
IF INSTR(s$, "bic") OR INSTR(s$, "cib") THEN
IF INSTR(a$, "i") <> 9 THEN
PRINT a$
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
permute a$
LOOP UNTIL a$ = h$
FUNCTION opp (x$, y$)
psnx = INSTR(a$, x$)
psny = INSTR(a$, y$)
o = 0
SELECT CASE psnx
CASE 5, 6
IF psnx + psny = 15 THEN o = 1
CASE ELSE
IF psny = 10 - psnx THEN o = 1
END SELECT
opp = o
END FUNCTION
finds
hdfaegcibj
as the sequence of participants going clockwise, starting at position 1, so the position in this string does not correspond to the numbering in the original diagram.
The host is J, as the last position clockwise from 1 is the one numbered 5 in the original diagram.
|
Posted by Charlie
on 2013-10-02 12:20:52 |