def validate_position(candidate: str):
    assert (
        len(candidate) == 8
    ), f

    valid_pieces = {: 2, : 2, : 2, : 1, : 1}
    assert {
        piece for piece in candidate
    } == valid_pieces.keys(), f
    for piece_type in valid_pieces.keys():
        assert (
            candidate.count(piece_type) == valid_pieces[piece_type]
        ), f

    bishops_pos = [index for index, value in enumerate(candidate) if value == ]
    assert (
        bishops_pos[0]% 2 != bishops_pos[1]% 2
    ), f

    assert [piece for piece in candidate if piece in ] == [
        ,
        ,
        ,
    ], 


def calc_position(start_pos: str):
    try:
        validate_position(start_pos)
    except AssertionError:
        raise AssertionError
    
    subset_step1 = [piece for piece in start_pos if piece not in ]
    nights_positions = [
        index for index, value in enumerate(subset_step1) if value == 
    ]
    nights_table = {
        (0, 1): 0,
        (0, 2): 1,
        (0, 3): 2,
        (0, 4): 3,
        (1, 2): 4,
        (1, 3): 5,
        (1, 4): 6,
        (2, 3): 7,
        (2, 4): 8,
        (3, 4): 9,
    }
    N = nights_table.get(tuple(nights_positions))

    
    subset_step2 = [piece for piece in start_pos if piece != ]
    Q = subset_step2.index()

    
    dark_squares = [
        piece for index, piece in enumerate(start_pos) if index in range(0, 9, 2)
    ]
    light_squares = [
        piece for index, piece in enumerate(start_pos) if index in range(1, 9, 2)
    ]
    D = dark_squares.index()
    L = light_squares.index()

    return 4 * (4 * (6*N + Q) + D) + L