Skip to content

Commit ec477bd

Browse files
author
Gonzalo Diaz
committed
[Hacker Rank] Interview Preparation Kit: Greedy Algorithms: Luck Balance. Clean Code improvement.
1 parent b878226 commit ec477bd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/hackerrank/interview_preparation_kit/greedy_algorithms/luck_balance.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ def luck_balance(k, contests: list) -> int:
3636

3737
total: int = 0
3838
size: int = len(important_contests)
39+
cut: int = min(k, size)
3940

40-
for i in range(0, min(k, size)):
41+
for i in range(0, cut):
4142
total += important_contests[i].luck
4243

43-
for i in range(min(k, size), size):
44+
for i in range(cut, size):
4445
total -= important_contests[i].luck
4546

4647
for contest in nonimportant_contests:

0 commit comments

Comments
 (0)