Question
A bench biologist in your lab has a culture of C. elegans worms and they are trying to predict the size of their culture each
A bench biologist in your lab has a culture of C. elegans worms and they are trying to predict the size of their culture each day. Most C. elegans are hermaphrodites, so they can reproduce without mating.
They tell you to assume that growth conditions are unlimited, and that the worms never die. They also tell you that it takes 1 day for a C. elegans individual to mature and, after maturation, each parent produces k children. They have a variety of C. elegans strains that each have a different k --they produce a different number of offspring each day (they have varying brood sizes).
They want to know: some n number of days from now, given a reproduction rate of k, how many worms will be present in the population?
You recognize that this is the same basic population growth problem solved by Pingala (Links to an external site.) in the 3rd century BCE, and later by Fibonacci (Links to an external site.) in the 12th century CE, and that is it especially amenable to dynamic programming techniques.
Create a file called fibonacci.py. In that file, write the following function:
1: population, which takes a day (integer, n, between 1 and 10000) and a reproduction rate (integer, k, between 1 and 10000) and returns the population size at day n.
Then, create an if __name__ == "__main__" block. That block should allow the user to pass a day and reproduction rate. Then, it should print the population size at the given day.
./fibonacci 10000 10000 should execute in less than a second: in other words, this problem must be solved with a dynamic programming approach, not recursive functions.
Hint: The number of daughter C. elegans animals produced each day is equal to offspring from the number of animals 2 days prior. So, between day n and day n+1, each animal that was alive on day n-1 produces k offspring.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started