During an uneventful period on the open sea, Captain Lafoot and his four mates decided to try their skill with muskets. They placed a target behind the forecastle and, keeping score they took turns shooting at it.
Based on the following statements, determine how each of five men ranked in the scoring.
 Captain Lafoot did not rank third unless Red Beard ranked fifth.
 If Long John ranked second, then Black Jack did not rank either first or third.
 If Will Kidd did not rank first, then Red Beard ranked second and Long John ranked fourth.
 If Black Jack did not rank first, then Long John ranked second and Captain Lafoot ranked fourth.
 If Black Jack did not rank second, then neither did Captain Lafoot nor Red Beard, unless Will Kidd ranked fourth.
' l = lafoot
' j = long john
' k = kidd
' b = black jack
' r = red beard
DECLARE SUB permute (a$)
CLS
a$ = "ljkbr": h$ = a$
DO
good = 1
IF MID$(a$, 3, 1) = "l" AND MID$(a$, 5, 1) <> "r" THEN good = 0
IF MID$(a$, 2, 1) = "j" AND (MID$(a$, 1, 1) = "b" OR MID$(a$, 3, 1) = "b") THEN good = 0
IF MID$(a$, 1, 1) <> "k" AND (MID$(a$, 2, 1) <> "r" OR MID$(a$, 4, 1) <> "j") THEN good = 0
IF MID$(a$, 1, 1) <> "b" AND (MID$(a$, 2, 1) <> "j" OR MID$(a$, 4, 1) <> "l") THEN good = 0
IF MID$(a$, 2, 1) <> "b" AND MID$(a$, 4, 1) <> "k" AND (MID$(a$, 2, 1) = "l" OR MID$(a$, 2, 1) = "r") THEN good = 0
IF good THEN PRINT a$
permute a$
LOOP UNTIL a$ = h$
finds
kjrlb
meaning the order of finish was
Will Kidd
Long John
Red Beard
Captain Lafoot
Black Jack

Posted by Charlie
on 20130207 15:08:32 