There are 60 records given to you which correspond to a prisoner who is imprisoned for 60
^{ } days. He has 6 relatives one of whom visits him daily and the others visit him every i
^{th} day from the day of his imprisonment (i=2,3,4,5,6 for these 5 relatives).
Every record is sealed with the day number on it which indicates the number of days he is jailed when the record is filed with the names of visitors on that particular day. You have to make a new record which should be filled with the following details:
visitor name  number of visits after 60 days
Assume that no other relatives visited him at all, names of these 6 relatives are different and you don't know their names. Find the minimum number of records that need to be checked to make the new record correctly. Find the number of ways you can choose the minimum number of records and you can still make the new record correctly.
here is the Qbasic program I used to find all the solutions
DATA 3,1,2,1,2,1
DATA 3,2,1,1,2,1
DATA 3,2,2,1,1,1
DATA 3,2,2,1,2,1
filen% = 1
OPEN "./perp.txt" FOR OUTPUT AS filen%
DIM mlts(1 TO 6, 1 TO 3)
DIM fls(1 TO 3)
DIM cnts(1 TO 6)
DIM ans(1 TO 4, 1 TO 6)
FOR i = 1 TO 4
FOR j = 1 TO 6
READ ans(i, j)
NEXT j
NEXT i
sols = 0
FOR f1 = 2 TO 58
FOR f2 = f1 + 1 TO 60
IF f2 <> f1 THEN
FOR f3 = f2 + 1 TO 60
IF f3 <> f2 AND f3 <> f1 THEN
fls(1) = f1
fls(2) = f2
fls(3) = f3
FOR i = 1 TO 6
tot = 0
FOR j = 1 TO 3
num = fls(j)
IF num MOD i = 0 THEN
mlts(i, j) = 1
tot = tot + 1
ELSE
mlts(i, j) = 0
END IF
NEXT j
cnts(i) = tot
NEXT i
pass = 1
FOR k = 1 TO 6
IF ans(1, k) <> cnts(k) THEN
pass = 0
END IF
NEXT k
IF pass = 0 THEN
pass = 1
FOR k = 1 TO 6
IF ans(2, k) <> cnts(k) THEN
pass = 0
END IF
NEXT k
END IF
IF pass = 0 THEN
pass = 1
FOR k = 1 TO 6
IF ans(3, k) <> cnts(k) THEN
pass = 0
END IF
NEXT k
END IF
IF pass = 1 THEN
sols = sols + 1
PRINT #filen%, f1, f2, f3
END IF
END IF
NEXT f3
END IF
NEXT f2
NEXT f1
PRINT #filen%, "found "; sols; " solutions"
CLOSE filen%

Posted by Daniel
on 20090121 22:22:03 