Someone please have a look at this problem, what should be the approach for this can anyone solve it?

  1. Write a function called do_allocation(number_of_people, number_of_buses)

  2. The function should return a list of number of people who can get into the next bus that
    comes in based on the following logic:

  3. Each bus’s capacity is the sum of the capacities of the previous two buses.

  4. Once all the people get in, then the buses can continue, but will have 0 people inside it.

    • This is the case when the number of people are less and there are more buses.
      So after all the people are already boarded, then the remaining buses will have 0
      people boarding.
  5. The output of the function is an array/list with the same length as number_of_buses.

  6. The total of this output array/list should be less than or equal to the number_of_people.

  7. The first bus’ capacity can be set to 1 by default.

E.g.
Def do_allocation(number_of_people, number_of_buses):
…. Your code….
Return array[number of people got into first bus, number of people got into second bus, …. ,
number of people who got into last bus]

I’m not sure these instructions are complete.

“Each bus’s capacity is the sum of the capacities of the previous two buses.”

“The first bus’ capacity can be set to 1 by default.”

So we know the capacity of the first bus, but I think we would need to know the capacity of the second bus as well since we don’t have two previous buses to add together to get the capacity.

what will the approach if we take capacity of 2nd bus 1 as well then for third we have previous two buses???

We won’t write the code you. What have you tried so far?

You could use fibonacci series kind of approach for this problem