'''simple docstring'''




from __future__ import annotations






def __lowerCAmelCase					(				UpperCamelCase__							,    UpperCamelCase__							)      ->       list[tuple[int, int]]:
    __lowerCamelCase      ,    __lowerCamelCase            =    position
    __lowerCamelCase            =    [
        (y + 1, x + 2),
        (y - 1, x + 2),
        (y + 1, x - 2),
        (y - 1, x - 2),
        (y + 2, x + 1),
        (y + 2, x - 1),
        (y - 2, x + 1),
        (y - 2, x - 1),
    ]
    __lowerCamelCase            =    []

    for position in positions:
        __lowerCamelCase      ,    __lowerCamelCase            =    position
        if 0 <= y_test < n and 0 <= x_test < n:
            permissible_positions.append(UpperCamelCase__							)

    return permissible_positions






def __lowerCAmelCase					(				UpperCamelCase__							)      ->       bool:
    return not any(elem == 0 for row in board for elem in row							)






def __lowerCAmelCase					(				UpperCamelCase__							,    UpperCamelCase__							,    UpperCamelCase__							)      ->       bool:

    if is_complete(UpperCamelCase__							):
        return True

    for position in get_valid_pos(UpperCamelCase__							,    len(UpperCamelCase__							)							):
        __lowerCamelCase      ,    __lowerCamelCase            =    position

        if board[y][x] == 0:
            __lowerCamelCase            =    curr + 1
            if open_knight_tour_helper(UpperCamelCase__							,    UpperCamelCase__							,    curr + 1							):
                return True
            __lowerCamelCase            =    0

    return False






def __lowerCAmelCase					(				UpperCamelCase__							)      ->       list[list[int]]:
    __lowerCamelCase            =    [[0 for i in range(UpperCamelCase__							)] for j in range(UpperCamelCase__							)]

    for i in range(UpperCamelCase__							):
        for j in range(UpperCamelCase__							):
            __lowerCamelCase            =    1
            if open_knight_tour_helper(UpperCamelCase__							,    (i, j)							,    1							):
                return board
            __lowerCamelCase            =    0

    __lowerCamelCase            =    f"""Open Kight Tour cannot be performed on a board of size {n}"""
    raise ValueError(UpperCamelCase__							)


if __name__ == "__main__":
  import doctest

  doctest.testmod()

'''simple docstring'''




import numpy as np






def __lowerCAmelCase					(				UpperCamelCase__							,    UpperCamelCase__							,    UpperCamelCase__							,    UpperCamelCase__							,    UpperCamelCase__							)      ->       str:
    __lowerCamelCase            =    int(np.ceil((x_end - xa) / h							)							)
    __lowerCamelCase            =    np.zeros((n + 1,)							)
    __lowerCamelCase            =    ya
    __lowerCamelCase            =    xa

    for k in range(UpperCamelCase__							):
        __lowerCamelCase            =    f(UpperCamelCase__							,    y[k]							)
        __lowerCamelCase            =    f(x + 0.5 * h							,    y[k] + 0.5 * h * ka							)
        __lowerCamelCase            =    f(x + 0.5 * h							,    y[k] + 0.5 * h * ka							)
        __lowerCamelCase            =    f(x + h							,    y[k] + h * ka							)
        __lowerCamelCase            =    y[k] + (1 / 6) * h * (ka + 2 * ka + 2 * ka + ka)
        x += h

    return y


if __name__ == "__main__":
  import doctest

  doctest.testmod()
