Skip to content

Commit

Permalink
Update walker_class.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Oct 31, 2024
1 parent eb5f025 commit af9d1c1
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion kyu_3/line_safari_is_that_a_line/walker_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Walker:
"""

def __init__(self, grid: list):
# print('__init__')
self.__grid: list = grid
self.__is_start: bool = True
self.__position: dict = self.__get_start_point()
Expand Down Expand Up @@ -158,6 +157,8 @@ def __set_direction(self) -> None:
self.__reset_direction()
print(f'prev: {previous_position}, pos: {self.position}')

case_i = self.__get_case_i(previous_position)

Check notice on line 160 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_3/line_safari_is_that_a_line/walker_class.py#L160

Unused variable 'case_i' (unused-variable)

Check warning on line 160 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

kyu_3/line_safari_is_that_a_line/walker_class.py#L160

Unused variable 'case_i'

if self.position == '+' and previous_position in '-X':
self.__direction['up'] = self.__test_up()
self.__direction['down'] = self.__test_down()
Expand Down Expand Up @@ -186,6 +187,46 @@ def __set_direction(self) -> None:
elif self.__position['row'] > self.__position['prev_row']:
self.__direction['down'] = self.__test_down()

def __get_case_i(self, previous_position) -> int:
"""
Get case i base on the current position vs previous_position
:param previous_position:
:return:
"""
i: int = 0

if self.position == '+' and previous_position in '-X':
i = 1

if self.position == '+' and previous_position == '|':
i = 2

if self.position == previous_position == '+' \
and self.__position['col'] == self.__position['prev_col']:
i = 3

if self.position == previous_position == '+' \
and self.__position['row'] == self.__position['prev_row']:
i = 4

if self.position == '-' and previous_position in '-X+' \
and self.__position['col'] < self.__position['prev_col']:
i = 5

if self.position == '-' and previous_position in '-X+' \
and self.__position['col'] > self.__position['prev_col']:
i = 6

if self.position == '|' and previous_position in '|X+' \
and self.__position['row'] < self.__position['prev_row']:
i = 7

if self.position == '|' and previous_position in '|X+' \
and self.__position['row'] > self.__position['prev_row']:
i = 8

return i

Check notice on line 228 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_3/line_safari_is_that_a_line/walker_class.py#L190-L228

Complex Method

def __test_up(self) -> bool:
row: int = self.__position['row']
col: int = self.__position['col']
Expand Down

0 comments on commit af9d1c1

Please sign in to comment.