The people and their qualifications are as follows:
HS 2Y VET REF
A 1 1 0 0
B 1 0 1 1
C 0 1 1 0
D 0 1 0 1
so that B had the most qualifications and was hired.
The program is as follows, treating sets of qualifications as binary numbers, where HS grad had value 8; 2yr exp, 4; veteran, 2 and references, 1.
DATA 3,5,6,9,10,12
CLS
FOR i = 1 TO 6: READ pair(i): NEXT
FOR a = 8 TO 15
FOR b = 8 TO 15
IF b AND 2 THEN
FOR c = 0 TO 15
IF (c AND 6) = 6 THEN
FOR d = 0 TO 15
IF (d AND 5) = 5 THEN
good = 1
FOR p = 1 TO 6
ct = 0
IF (a AND pair(p)) = pair(p) THEN ct = ct + 1
IF (b AND pair(p)) = pair(p) THEN ct = ct + 1
IF (c AND pair(p)) = pair(p) THEN ct = ct + 1
IF (d AND pair(p)) = pair(p) THEN ct = ct + 1
IF ct <> 1 THEN good = 0
NEXT
IF good THEN
x = a: s$ = ""
FOR i = 1 TO 4
s$ = STR$(x MOD 2) + s$
x = x \ 2
NEXT
PRINT s$
x = b: s$ = ""
FOR i = 1 TO 4
s$ = STR$(x MOD 2) + s$
x = x \ 2
NEXT
PRINT s$
x = c: s$ = ""
FOR i = 1 TO 4
s$ = STR$(x MOD 2) + s$
x = x \ 2
NEXT
PRINT s$
x = d: s$ = ""
FOR i = 1 TO 4
s$ = STR$(x MOD 2) + s$
x = x \ 2
NEXT
PRINT s$
END IF
END IF
NEXT
END IF
NEXT
END IF
NEXT
NEXT

Posted by Charlie
on 20051219 14:16:30 