-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path991.py
31 lines (31 loc) · 994 Bytes
/
991.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
__________________________________________________________________________________________________
sample 24 ms submission
class Solution:
def brokenCalc(self, X: int, Y: int) -> int:
if Y<X:
return X-Y
count = 0
while X !=Y:
if Y<X:
count = count + X-Y
return int(count)
elif Y%2 ==0:
Y/=2
count+=1
else:
Y+=1
count+=1
return count
__________________________________________________________________________________________________
sample 13068 kb submission
class Solution:
def brokenCalc(self, X: int, Y: int) -> int:
count = 0
while Y > X:
if Y % 2 == 0:
Y = Y // 2
else:
Y = Y + 1
count += 1
return count + (X - Y)
__________________________________________________________________________________________________