質問

We download 3 webpages per hour max, for 6 hours.

We have to download again and again the same webpage to check for changes. We have the webpages split in two categories:

Priority B: each webpage here must be downloaded once per 2 hours
Priority C: each webpage here must be downloaded once per 3 hours

We have 3 items in priority B and 4 in priority C. This means, for each hour on average:

we must download 3/2 = 1.5 B items
we must download 4/3 = 1.333 C items

On 6 hours: (1.5+1.333)*6 = 17 items.

This proves the problem may have a solution with 17 steps.

My attempt (using 18 steps):

Hour 1: B0 C0 B1
Hour 2: C1 B2 C2
Hour 3: B0 C3 B1
Hour 4: C0 B2 C2
Hour 5: B0 C1 B1
Hour 6: C3 B2 C2

The problem:

We take C0 once every 3 hours. The same applies to C1 and C3. We also take B0, B1 and B2 once every 2 hours. Those are fine.

We take C2 once every 2 hours. This puzzles me. Using pencil and paper I failed to mathematically prove that solving the problem is possible by taking C2 once every 3 hours.

Question: Is it possible, for someone to modify my attempt, to use only 17 steps and download C2 once every 3 hours?

役に立ちましたか?

解決

It depends if you need to stick to doing things on the hour. ie how your time restritions work. IF you keep it the same but fetch C2 at the start of hour 2 and right at the end of hour 4 then there is just short of three hours different and then skipping the C2 in hour 6 and assuming looping then just over three hours between the end of hour 4 and the beginning of hour 2.

Otherwise there is no way of doing it using just time slots. The reason is that you have to have at least one hour where you are checking 2 of the priority C items. Because you check it again three hours later there is an odd hour and an even hour that have 2 priority C checks. Since the B items check on all even or all odd hours then you would be limited to only two of them (one on odd and one on even) so you couldn't do it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top