Broken Calculator LeetCode solution in Python
1class Solution(object):2def brokenCalc(self, startValue, target):3"""4:type startValue: int5:type target: int6:rtype: int7"""8res = 09while target > startValue:10res += 111if target % 2:12target += 113else:14target //= 215return res + startValue - target