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 a65f6d3 commit ca250c3
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions kyu_4/range_extraction/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,7 @@ def solution(args: list) -> str:
result = case_2(a, i, current, result)

# case 3
if i == len(args) - 1 and not current[2]:
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 = case_3(args, a, i, current, result)

# case 4
if i == len(args) - 1 and current[-1] != a and current[2]:
Expand All @@ -42,7 +34,30 @@ def solution(args: list) -> str:
return result


def case_2(a: int, i: int, current: list, result: str) -> str:
def case_3(args: list, a: int, i: int, current: list, result: str) -> str:

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

View check run for this annotation

codefactor.io / CodeFactor

kyu_4/range_extraction/solution.py#L37

Argument name "a" doesn't conform to snake_case naming style (invalid-name)
"""
Case #3
:param args:
:param a:
:param i:
:param current:
:param result:
:return:

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

View check run for this annotation

codefactor.io / CodeFactor

kyu_4/range_extraction/solution.py#L45

Argument name "a" doesn't conform to snake_case naming style (invalid-name)
"""
if i == len(args) - 1 and not current[2]:
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])

return result


def case_2(a: int, i: int, current: list, result: str) -> str:
"""
Case #2
:param i:
Expand Down

0 comments on commit ca250c3

Please sign in to comment.