MegaTech Insurance Co. has just bought out Old Line Insurance from Stodgy Corp. They have put the 10,000 policies from Old Line into their computer system, and today they will begin accepting new policies. Everything is computerized, but just to make sure, they will follow Old Line's long-time practice and have Old Foskins double-check all the policies.
The policies are stored alphabetically in the computer. Each morning a technician prints out the next 100 policies in sequence for Old Foskins to check by paper and pencil examination. Each evening 200 new policies are merged into the computer in alphabetic order.
How long will it take Old Foskins to reach the end of the list?
Assuming the old policies and the new policies as they some in are perfectly distributed along the alphabet; and assuming that as new policies come in, if they occur earlier in the alphabet than Old Foskins is currently checking, then these earlier ones will never get checked.
An average of 100 runs showed 316.91 days; call it 317.
---------
import random
daylist = []
reps = 100
for rep in range(reps):
policies = [i for i in range(10000)]
day = 0
current_policy = 0
while current_policy < 10000:
day += 1
location = policies.index(current_policy) + 100
if location > len(policies):
break
current_policy = policies[location]
new_policies = [random.uniform(1, 10000) for i in range(200)]
policies = sorted(policies + new_policies)
progress = policies.index(current_policy) / len(policies)
daylist.append(day)
print(sum(daylist)/reps)
|
Posted by Larry
on 2023-12-14 14:50:42 |