total number of different mixes

838 Views Asked by At

Patient Age             Avg Visits / Year
<1 year                 7.5
1-4 years               3.0
5-14 years              1.8
15-24 years             1.7
25-44 years             2.6
45-64 years             4.0
65-74 years             6.7
>75 years              8.2
The table above breaks out, by age range, the average number of visits people make to physicians each year. If you were an insurance company that wanted a member mix that would average 50 physician visits per year, you could sign up either of the following two member mixes:

  • 10 members in the "1-4 years" age range and 5 members in the "45-64 years" age range resulting in (10 x 3.0) + (5 x 4.0) = 50

  • 2 members in the "<1 year" age range, 10 members in the "5-14 years" age range and 10 members in the "15-24 years" age range resulting in (2 x 7.5) + (10 x 1.8) + (10 x 1.7) = 50

Note that there are many more possibilities.

Question 1: What is the total number of different member mixes that result in 50 physician visits per year?
Question 2: What is the total number of different member mixes that result in 200 physician visits per year?
Question 3: What is the total number of different member mixes that result in 5000 physician visits per year?

1

There are 1 best solutions below

2
On

This problem can be solved using dynamic programming. Here is some python code:

avg_visits = [75, 30, 18, 17, 26, 40, 67, 82]
mixes = [0]*50001
mixes[0] = 1

for n in avg_visits:
  for i in range(0,50001):
    if (i+n <= 50000):
      mixes[i+n] = mixes[i]+mixes[i+n]

print mixes[500]
print mixes[2000]
print mixes[50000]

I get

mixes[500]   = 3071
mixes[2000]  = 11620716
mixes[50000] = 40392472974290151