In the first sample, Limak weighs 4 and Bob weighs 7 initially. After one year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is tripled while the other one is doubled). Limak isn't larger than Bob yet. After the second year weights are 36 and 28, so the first weight is greater than the second one. Limak became larger than Bob after two years so you should print 2.
Assistant
First, I need to understand what's being asked: ## Note
In the first sample, Limak weighs 4 and Bob weighs 7 initially. After one year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is tripled while the other one is doubled). Limak isn't larger than Bob yet. After the second year weights are 36 and 28, so the first weight is gre
Key values given: ,, 4, 7, 4, 3, 12, 7, 2
Working through the calculation: Solution: Bear Big Brother Problem
Problem Understanding
We have two weights:
Limak's weight: triples each year (multiplied by 3)
Bob's weight: doubles each year (multiplied by 2)
We need to find the minimum number of years until Limak's weight becomes strictly greater than Bob's weight. Mathematical Analysis
Let Limak's initial weight = a and Bob's initial weight = b. After n years:
Limak's weight = a×3n
Bob's weight = b×2n
We need: a×3n>b×2n
Solving for n:
2n3n>
Solution Approaches
Approach 1: Iterative (Recommended for Programming)
python
def years_to_exceed(a, b):
years = 0
while a <= b:
a = 3
b = 2
years += 1
return years