Skip to content

Commit

Permalink
Update solution.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Nov 7, 2024
1 parent ca250c3 commit 5256018
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions kyu_4/range_extraction/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ def solution(args: list) -> str:
continue

# case 2
result = case_2(a, i, current, result)
result = case_2(a=a, i=i, current=current, result=result)

# case 3
result = case_3(args, a, i, current, result)
if i == len(args) - 1 and not current[2]:
result = case_3(args=args, a=a, i=i, current=current, result=result)

# case 4
if i == len(args) - 1 and current[-1] != a and current[2]:
Expand All @@ -44,20 +45,19 @@ def case_3(args: list, a: int, i: int, current: list, result: str) -> str:
:param result:
:return:
"""
if i == len(args) - 1 and not current[2]:
if current[1] + 1 == a:
current[1] = a
if current[1] + 1 == a:
current[1] = a

result += str(current[0])
if abs(current[1] - current[0]) >= 2:
result += '-' + str(current[1])
elif current[0] != current[1]:
result += ',' + str(current[1])
result += str(current[0])
if abs(current[1] - current[0]) >= 2:
result += '-' + str(current[1])
elif current[0] != current[1]:
result += ',' + str(current[1])

return result


def case_2(a: int, i: int, current: list, result: str) -> str:
def case_2(**kwargs) -> str:
"""
Case #2
:param i:
Expand All @@ -66,6 +66,12 @@ def case_2(a: int, i: int, current: list, result: str) -> str:
:param result:
:return:
"""

a: int = kwargs['a']

Check notice on line 70 in kyu_4/range_extraction/solution.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_4/range_extraction/solution.py#L70

Variable name "a" doesn't conform to snake_case naming style (invalid-name)
i: int = kwargs['i']
current: list = kwargs['current']
result: str = kwargs['result']

if a == current[1] + 1:
current[1] = a
current[2] = False
Expand Down

0 comments on commit 5256018

Please sign in to comment.