All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Prisoner's Visitors Problem (Posted on 2009-01-21)
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 ith 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.

 See The Solution Submitted by Praneeth Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer calculation Comment 7 of 7 |

Given that it's been settled that 3 are necessary and sufficient, the following program determines the 80 sets of 3 that will work.

OPEN "prisvis.txt" FOR OUTPUT AS #2
FOR a = 1 TO 58
FOR b = a + 1 TO 59
FOR c = b + 1 TO 60

FOR i = 1 TO 6
IF a MOD i = 0 THEN result(i) = 4:  ELSE result(i) = 0
IF b MOD i = 0 THEN result(i) = result(i) OR 2
IF c MOD i = 0 THEN result(i) = result(i) OR 1
NEXT

good = 1
FOR i = 1 TO 5
IF result(i) = 0 THEN good = 0
FOR j = i + 1 TO 6
IF result(i) = result(j) THEN good = 0
NEXT
NEXT
IF result(6) = 0 THEN good = 0

IF good THEN
PRINT a; b; c; : ct = ct + 1
FOR i = 1 TO 6
PRINT LTRIM\$(STR\$(result(i)));
NEXT
PRINT
PRINT #2, a; b; c;
FOR i = 1 TO 6
PRINT #2, LTRIM\$(STR\$(result(i)));
NEXT
PRINT #2,
END IF

NEXT
NEXT
NEXT
PRINT ct

The table shows all the sets. After each set of three, there is a set of six digits, each digit representing one of the visitors.  If the digit that represnts any given visitor is represented in binary, it tells, by its three binary digits, which of the three records will show his name.

For example, the first set in the right hand column is 15, 18, 52. The sequence of visitor digits is 736142, indicating visitor 1 will be on all three (7=111), visitor 2 will be on only the last two (3=011), visitor 3 will be on only the first two (6=110), visitor 4 will be on only the last record (1=001), visitor 5 on only the first record (4=100) and visitor 6 on only the middle record (2=010).

` 4  6  15 763412           15  18  52 736142 4  6  45 763412           15  18  56 736142 4  15  18 753421          15  20  42 735261 4  15  42 753421          15  20  54 735261 4  15  54 753421          15  28  42 735241 4  18  45 763412          15  28  54 735241 4  42  45 763412          15  32  42 735241 4  45  54 753421          15  32  54 735241 6  8  15 765214           15  40  42 735261 6  8  45 765214           15  40  54 735261 6  15  16 756124          15  42  44 736142 6  15  20 756134          15  42  52 736142 6  15  28 756124          15  42  56 736142 6  15  32 756124          15  44  54 735241 6  15  40 756134          15  52  54 735241 6  15  44 756124          15  54  56 736142 6  15  52 756124          16  18  45 763412 6  15  56 756124          16  42  45 763412 6  16  45 765214          16  45  54 753421 6  20  45 765234          18  20  45 765234 6  28  45 765214          18  28  45 765214 6  32  45 765214          18  32  45 765214 6  40  45 765234          18  40  45 765234 6  44  45 765214          18  44  45 765214 6  45  52 756124          18  45  52 756124 6  45  56 756124          18  45  56 756124 8  15  18 753421          20  42  45 763452 8  15  42 753421          20  45  54 753461 8  15  54 753421          28  42  45 763412 8  18  45 763412          28  45  54 753421 8  42  45 763412          32  42  45 763412 8  45  54 753421          32  45  54 753421 15  16  18 735241         40  42  45 763452 15  16  42 735241         40  45  54 753461 15  16  54 735241         42  44  45 765214 15  18  20 736152         42  45  52 756124 15  18  28 736142         42  45  56 756124 15  18  32 736142         44  45  54 753421 15  18  40 736152         45  52  54 735241 15  18  44 736142         45  54  56 736142 `

 Posted by Charlie on 2009-01-22 03:38:04

 Search: Search body:
Forums (2)