Skip to content

Commit cecd0a4

Browse files
authored
Update minimum-number-of-pushes-to-type-word-i.py
1 parent b2bea98 commit cecd0a4

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

Python/minimum-number-of-pushes-to-type-word-i.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ def minimumPushes(self, word):
1111
def ceil_divide(a, b):
1212
return (a+b-1)//b
1313

14-
result, cnt = 0, len(word)
15-
for i in xrange(1, 1+ceil_divide(cnt, (9-2+1))):
16-
g = min(cnt, (9-2+1))
17-
cnt -= g
18-
result += i*g
19-
return result
14+
return sum(i*min(len(word)-(i-1)*(9-2+1), (9-2+1)) for i in xrange(1, ceil_divide(len(word), (9-2+1))+1))
2015

2116

2217
# Time: O(26)

0 commit comments

Comments
 (0)