def test_fit(x, y, n, board_state):
    """
    tests whether n can be placed in x,y on the current board_state
    :param x: horizontal position on the board
    :param y: vertical position on the board
    :param n: the number to place
    :param board_state: the current board state as a numpy array
    :return: true if nothing would stop n from being placed in x,y on board_state, else returns false
    """

    # first test if something is already in that position
    if board_state[x, y] != 0:
        return False

    # then test if n already exists in that column or row
    for i in range(9):
        if board_state[x, i] == n:
            return False
        elif board_state[i, y] == n:
            return False

    # finally test if it fits in the block
    x_block = 0
    y_block = 0

    if x < 3:
        x_block = 0
    elif x < 6:
        x_block = 1
    else:
        x_block = 2

    if y < 3:
        y_block = 0
    elif y < 6:
        y_block = 1
    else:
        y_block = 2

    for i in range(x_block * 3, x_block * 3 + 3):
        for j in range(y_block * 3, y_block * 3 + 3):
            if board_state[i, j] == n:
                return False

    return True