python/CodeChallenge_15.py

26 lines
531 B
Python

'''
Given an integer a and an integer b, return the smallest integer n such that if a is tripled n times and b is doubled n times, a exceeds b.
Example 1
Input:
a = 17; b = 100
Output:
5
'''
class Solution:
def solve(self, a:int, b:int) -> int:
print(f"a: {a}, b: {b}")
triple = a
double = b
n = 0
while triple < double:
n += 1
triple *= 3
double *= 2
return n
s = Solution()
print(s.solve(17, 100))
print(s.solve(4, 16806))