Six magicians A, B, C, D, E, F live in an island. Every Monday, the elders of the island rank the six magicians on their performance during the previous six days.
The rankings published on the previous Monday listed A 1st, B 2nd, C 3rd, D 4th, E 5th and F 6th.
This Monday’s ranking has each magician ranked in a different position than that of the previous Monday. We know that:
1. B’s change in ranking is greatest among the six magicians.
2. The product of D’s rankings for the two weeks is the same as the product of F’s rankings for the two weeks.
Determine the new rankings.
(In reply to
solution by Charlie)
DECLARE SUB permute (a$)
CLS
a$ = "abcdef": h$ = a$
DO
good = 1
FOR i = 1 TO 6
IF MID$(a$, i, 1) = MID$(h$, i, 1) THEN good = 0: EXIT FOR
NEXT
IF good THEN
ac = ABS(INSTR(a$, "a") - INSTR(h$, "a"))
bc = ABS(INSTR(a$, "b") - INSTR(h$, "b"))
cc = ABS(INSTR(a$, "c") - INSTR(h$, "c"))
dc = ABS(INSTR(a$, "d") - INSTR(h$, "d"))
ec = ABS(INSTR(a$, "e") - INSTR(h$, "e"))
fc = ABS(INSTR(a$, "f") - INSTR(h$, "f"))
IF bc > ac AND bc > cc AND bc > dc AND bc > ec AND bc > fc THEN
d = INSTR(a$, "d")
f = INSTR(a$, "f")
IF 6 * f = 4 * d THEN
PRINT a$
END IF
END IF
END IF
permute a$
LOOP UNTIL a$ = h$
also produces
caefbd
|
Posted by Charlie
on 2007-05-08 21:30:26 |