Dear RebelCoder this is my coding to solve Rabbits and Recurrence relations month_total_pair = {1: 1, 2: 1} n = int(input("Please Enter Month! : N = ")) k = int(input("Please Enter litter of rabbit pairs! : k = ")) if n == 1 or n == 2: print(month_total_pair[n]) else: for x in range(3, 41): total_pair = month_total_pair[x-1] + month_total_pair[x-2] * k month_total_pair.update({x: total_pair}) print(month_total_pair[n])
apparently there are different ways of counting the resulting bunnies after a given number of months. Below is the code that was mentioned in the video that starts with parent and children starting at 1. def fib_bunnies2(months,offspring): parent,child = 1,1 for itr in range(months - 1): child,parent = parent, parent + (child * offspring) return child fib_bunnies2(5,2) However, this implementation does not reflect the diagram that was show below the code in the video. The code below shows how the code should be written to match the diagram: def fib_bunnies(months, offspring): child, parents = 1, 0 for itr in range(months - 1): child, parents = parents * offspring, child + parents return (child + parents) fib_bunnies(5,2) Notice that inside the for loop there is different ways of incrementing the child and parent variables to result to the same result. credit goes to @Вася Иванов for their comment in this video and helping realize a hidden nuance in recursion. Thanks!
this is one of the most information rich tutorial channels that I've ever seen
Thank you so much! Glad you find the content valuable!
I'm enjoying this series so much! I had already done some of the problems but it's very nice to see your explanation and programming.
Thank you so much.
Dear RebelCoder
this is my coding to solve Rabbits and Recurrence relations
month_total_pair = {1: 1, 2: 1}
n = int(input("Please Enter Month! : N = "))
k = int(input("Please Enter litter of rabbit pairs! : k = "))
if n == 1 or n == 2:
print(month_total_pair[n])
else:
for x in range(3, 41):
total_pair = month_total_pair[x-1] + month_total_pair[x-2] * k
month_total_pair.update({x: total_pair})
print(month_total_pair[n])
спасибо за видео!
great explanation..keep up the good work..
How do you do a bulk rename at 6:59?
edit:
Okay I see you do it by right clicking on the word you wish to rename and hitting rename symbol.
it works for final "children" value count, but matching visualisation and code "parents" looks little bit odd.
my point is:
1) initial values: children, parents = 1, 0
2) inside for loop: children, parents = parents * offspring, children + parents
3) return (children + parents)
@@ВасяИванов-щ6з ohhh I had a question about this! thank you!
Do you mind if I translate your videos into Russian and upload them to RUclips?
are you taking a break from making video?
Nope. I was working on something else, related to Bioinformatics. Expect new videos very soon.
@@rebelScience nice
why did you start with parent = 1, and child = 1, when in the first month there is only 1 child and 0 parents?
apparently there are different ways of counting the resulting bunnies after a given number of months. Below is the code that was mentioned in the video that starts with parent and children starting at 1.
def fib_bunnies2(months,offspring):
parent,child = 1,1
for itr in range(months - 1):
child,parent = parent, parent + (child * offspring)
return child
fib_bunnies2(5,2)
However, this implementation does not reflect the diagram that was show below the code in the video. The code below shows how the code should be written to match the diagram:
def fib_bunnies(months, offspring):
child, parents = 1, 0
for itr in range(months - 1):
child, parents = parents * offspring, child + parents
return (child + parents)
fib_bunnies(5,2)
Notice that inside the for loop there is different ways of incrementing the child and parent variables to result to the same result.
credit goes to @Вася Иванов for their comment in this video and helping realize a hidden nuance in recursion. Thanks!
go ahead