Four men -- Aaron, Barry, Colin & David and four women -- Marie, Norma, Olive & Pearl -- attended a wedding.
- One of the four men married one of the four women.
- If neither Aaron nor Marie got married, then Olive got married.
- If neither Aaron nor Norma got married, then Barry got married.
- If neither Barry nor Olive got married, then Colin got married.
- If neither Colin nor Norma got married, then Marie got married.
Who got married?
The following table could have been done by hand:
Initials status
A M violates rule: 4
A N violates rule: 4
A O violates rule: 5
A P violates rules: 4 5
B M answer
B N violates rule: 2
B O violates rule: 5
B P violates rules: 2 5
C M violates rule: 3
C N violates rule: 2
C O violates rule: 3
C P violates rules: 2 3
D M violates rules: 3 4
D N violates rules: 2 4
D O violates rules: 3 5
D P violates rules: 2 3 4 5
But was actually produced by
DIM men AS STRING, women AS STRING
CLS
men = "ABCD": women = "MNOP"
FOR m = 1 TO 4
FOR w = 1 TO 4
bad = 0
IF m <> 1 AND w <> 1 AND w <> 3 THEN bad = 1
IF m <> 1 AND w <> 2 AND m <> 2 THEN bad = bad + 2
IF m <> 2 AND w <> 3 AND m <> 3 THEN bad = bad + 4
IF m <> 3 AND w <> 2 AND w <> 1 THEN bad = bad + 8
PRINT MID$(men, m, 1); " "; MID$(women, w, 1),
IF bad = 0 THEN
PRINT "answer"
ELSE
PRINT "violates rule";
IF bad = 1 OR bad = 2 OR bad = 4 OR bad = 8 THEN
PRINT ": ";
ELSE
PRINT "s: ";
END IF
IF bad AND 1 THEN PRINT "2 ";
IF bad AND 2 THEN PRINT "3 ";
IF bad AND 4 THEN PRINT "4 ";
IF bad AND 8 THEN PRINT "5 ";
PRINT
END IF
NEXT
NEXT
|
Posted by Charlie
on 2013-05-03 12:39:18 |