Bear and Big Brother

Practice this coding question on Coding Gurukul.

Problem statement

A wildlife learning centre runs a mathematical growth simulation for two bears. Limak starts no heavier than Bob. At the end of each simulated year, Limak’s recorded weight triples while Bob’s recorded weight doubles. The numbers describe the simulation rather than a prediction about real animals. The centre wants to show visitors the first year in which Limak becomes strictly heavier. Your task Given the two initial positive integer weights a and b, repeatedly apply both annual growth rules and count completed years. Return the smallest number of years after which Limak’s weight is greater than Bob’s. Both weights change during each year before the comparison for that year is made. Important details Equality does not count as becoming heavier. Even when both initial weights are equal, at least one year must pass. Compare updated weights, not one updated value against one old value. Worked example With a = 2 and b = 3, the first year ends at 6 and 6. After the second year the weights are 18 and 12, so the answer is 2.

Input format

Two space-separated integers a and b.

Output format

Print the first qualifying year number.

Constraints

1 <= a <= b <= 10.

Sample input

2 3

Sample output

2

Sign in to run or submit a solution in C++, Java or Python.