kyu_3.line_safari_is_that_a_line package

Submodules

kyu_3.line_safari_is_that_a_line.line_safari module

Solution for -> Line Safari - Is that a line?…

Created by Egor Kostan. GitHub: https://github.com/ikostan

kyu_3.line_safari_is_that_a_line.line_safari.assert_x_has_rout(grid: list) bool[source]

Make sure x has a valid route.

Parameters:

grid

Returns:

kyu_3.line_safari_is_that_a_line.line_safari.line(grid: list) bool[source]

You are given a grid.

You simply need to return true/false if you can detect a one and only one “valid” line joining those points. :param grid: which always includes exactly two end-points indicated by X :return: true/false

kyu_3.line_safari_is_that_a_line.line_safari.x_counter(grid: list) int[source]

Counter number of X.

Parameters:

grid – list

Returns:

int

kyu_3.line_safari_is_that_a_line.test_line_negative module

Testing Line Safari functionality.

Negative test cases. Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_3.line_safari_is_that_a_line.test_line_negative.LineNegativeTestCase(methodName='runTest')[source]

Bases: TestCase

Testing Line Safari functionality.

_classSetupFailed = False
_class_cleanups = []
test_line_negative = None
test_line_negative_0(**kw)

Negative test cases [with grid=[‘X—–\|—-X’]].

Parameters:

grid

Returns:

test_line_negative_1(**kw)

Negative test cases [with grid=[’ X ‘, ‘ \| ‘, ‘ + ‘, ‘ X ‘]].

Parameters:

grid

Returns:

test_line_negative_2(**kw)

Negative test cases [with grid=[’ \|——–+ ‘, ‘X— … \| ‘, ‘ X ‘]].

Parameters:

grid

Returns:

test_line_negative_3(**kw)

Negative test cases [with grid=[’ ‘, ‘ +—— …-+ X ‘, ‘ ‘]].

Parameters:

grid

Returns:

test_line_negative_4(**kw)

Negative test cases [with grid=[’ +——+’, ‘ \| … \| ‘, ‘ X ‘]].

Parameters:

grid

Returns:

kyu_3.line_safari_is_that_a_line.test_line_positive module

Testing Line Safari functionality.

Positive test cases. Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_3.line_safari_is_that_a_line.test_line_positive.LinePositiveTestCase(methodName='runTest')[source]

Bases: TestCase

Testing Line Safari functionality.

_classSetupFailed = False
_class_cleanups = []
pytestmark = [Mark(name='skip', args=(), kwargs={'reason': 'The solution is not ready'})]
test_line_positive = None
test_line_positive_0(**kw)

Positive test cases [with grid=[’ ‘, ‘X———X’, ‘ ‘, ‘ ‘]].

Parameters:

grid

Returns:

test_line_positive_1(**kw)

Positive test cases [with grid=[’ ‘, ‘ X ‘, ‘ \| ‘, ‘ \| ‘, ‘ X ‘]].

Parameters:

grid

Returns:

test_line_positive_2(**kw)

Positive test cases [with grid=[’ ‘, ‘ +… X ‘, ‘ ‘]].

Parameters:

grid

Returns:

test_line_positive_3(**kw)

Positive test cases [with grid=[’ ‘, ‘ +…–+ ‘, ‘ ‘]].

Parameters:

grid

Returns:

test_line_positive_4(**kw)

Positive test cases [with grid=[’ +—-+ ‘, ‘ \|+–+\|… +—+\| ‘, ‘X——–+ ‘]].

Parameters:

grid

Returns:

test_line_positive_5(**kw)

Positive test cases [with grid=[’ +—–+ ‘, ‘ \|+—+\|… X\|+–+\| ‘, ‘ +—-+ ‘]].

Parameters:

grid

Returns:

test_line_positive_6(**kw)

Positive test cases [with grid=[’ ‘, ‘ +… ‘, ‘X–+ +-+ X ‘]].

Parameters:

grid

Returns:

kyu_3.line_safari_is_that_a_line.test_walker module

Testing Walker Class.

Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_3.line_safari_is_that_a_line.test_walker.WalkerClassTestCase(methodName='runTest')[source]

Bases: TestCase

Testing Walker class.

_classSetupFailed = False
_class_cleanups = []
test_starting_position_from_negatives = None
test_starting_position_from_negatives_0(**kw)

Testing Walker class [with grid=[‘X—–\|—-X’]].

Testing starting position property based on negative grids. :param grid: :return:

test_starting_position_from_negatives_1(**kw)

Testing Walker class [with grid=[’ X ‘, ‘ \| ‘, ‘ + ‘, ‘ X ‘]].

Testing starting position property based on negative grids. :param grid: :return:

test_starting_position_from_negatives_2(**kw)

Testing Walker class [with grid=[’ \|——–+ ‘, ‘X— … \| ‘, ‘ X ‘]].

Testing starting position property based on negative grids. :param grid: :return:

test_starting_position_from_negatives_3(**kw)

Testing Walker class [with grid=[’ ‘, ‘ +—— …-+ X ‘, ‘ ‘]].

Testing starting position property based on negative grids. :param grid: :return:

test_starting_position_from_negatives_4(**kw)

Testing Walker class [with grid=[’ +——+’, ‘ \| … \| ‘, ‘ X ‘]].

Testing starting position property based on negative grids. :param grid: :return:

test_starting_position_from_positives = None
test_starting_position_from_positives_0(**kw)

Testing Walker class [with grid=[’ ‘, ‘X———X’, ‘ ‘, ‘ ‘]].

Testing starting position property based on positive grids. :param grid: :return:

test_starting_position_from_positives_1(**kw)

Testing Walker class [with grid=[’ ‘, ‘ X ‘, ‘ | ‘, ‘ | ‘, ‘ X ‘]].

Testing starting position property based on positive grids. :param grid: :return:

test_starting_position_from_positives_2(**kw)

Testing Walker class [with grid=[’ ‘, ‘ +… X ‘, ‘ ‘]].

Testing starting position property based on positive grids. :param grid: :return:

test_starting_position_from_positives_3(**kw)

Testing Walker class [with grid=[’ ‘, ‘ +…–+ ‘, ‘ ‘]].

Testing starting position property based on positive grids. :param grid: :return:

test_starting_position_from_positives_4(**kw)

Testing Walker class [with grid=[’ ‘, ‘ +… ‘, ‘X–+ +-+ X ‘]].

Testing starting position property based on positive grids. :param grid: :return:

kyu_3.line_safari_is_that_a_line.walker_class module

Walker class: make moves, check directions, etc.

Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_3.line_safari_is_that_a_line.walker_class.Walker(grid: list)[source]

Bases: object

Walker class: make moves, check directions, etc.

__get_start_point() dict

Locate starting point.

Returns:

dict, starting point X

__reset_direction() None
__set_direction() None

Update directions based on current position and previous direction.

Returns:

None

__set_initial_direction() dict

Set initial direction.

Returns:

dict

__test_down() bool

Test down.

Returns:

bool

__test_left() bool

Test left.

Returns:

bool

__test_right() bool

Test right.

Returns:

bool

__test_up() bool

Test up.

Returns:

bool

property is_done: bool

Check if get to the ‘X’ point or can make one move only.

Returns:

bool

move() None[source]

Make one step if possible.

Returns:

None

property position: str

Return char from grid based on current position.

Returns:

str, current char

position_minus(previous_position: str) None[source]

Process cells if current position is -.

Parameters:

previous_position – str

Returns:

None

position_pipe(previous_position: str) None[source]

Process cells if current position is ‘|’.

Parameters:

previous_position – str

Returns:

None

position_plus(previous_position: str) None[source]

Process cells if current position is +.

Parameters:

previous_position – str

Returns:

None

Module contents

Codewars kyu_3 package: Line Safari - Is that a line.