<commit_before># -*- coding: utf-8 -*-
import itertools

# pieces
KING = 1
QUEEN = 2
BISHOP = 3
ROOK = 4
KNIGHT = 5

def get_col_by_index(index, N):
    return index % N

def get_line_by_index(index, M):
    if index < M:
        return 1
    elif index == M:
        return 2
    elif index >= (M - 1) * M:
        return M
    else:
        for l in range(2, M):
            if index >= (l - 1) * M and index < l * M:
                return l
    return -1


def mirror_king(index, mirror, configuration, M, N):
    """
    Mirror King's position where it could attack. Returns false if there is a piece in that space.
    A king moves one space to every side.
    """

    col = get_col_by_index(index, N)
    line = get_line_by_index(index, M)

    # mirror to right (if possible)
    if col < (N - 1):
        if configuration[index + 1] != 0:
            return False
        else:
            mirror[index + 1] = KING

    # mirror to left (if possible)
    if col > 0:
        if configuration[index - 1] != 0:
            return False
        else:
            mirror[index - 1] = KING

    # mirror down (if possible)
    if line < M:
        if configuration[index + 3] != 0:
            return False
        else:
            mirror[index + 3] = KING

    # mirror up (if possible)
    if line > 1:
        if configuration[index - 3] != 0:
            return False
        else:
            mirror[index - 3] = KING

    # Diagonals

    # upper left
    if col > 0 and line > 1:
        if configuration[index - 3 - 1] != 0:
            return False
        else:
            mirror[index - 3 - 1] = KING

    # down left
    if col > 0 and line < M:
        if configuration[index + 3 - 1] != 0:
            return False
        else:
            mirror[index + 3 - 1] = KING

    # upper right
    if col < (N - 1) and line > 1:
        if configuration[index - 3 + 1] != 0:
            return False
        else:
            mirror[index - 3 + 1] = KING

    # down right
    if col < (N - 1) and line < M:
        if configuration[index + 3 + 1] != 0:
            return False
        else:
            mirror[index + 3 + 1] = KING

    return True


def mirror_rook(index, mirror, configuration, M, N):
    """
    Mirror Rook's position where it could attack. Returns false if there is a piece in that space.
    A ROOK moves through intire line and column from its position
    """
    
    col = get_col_by_index(index, N)
    line = get_line_by_index(index, M)

    # mirror to right (if possible)
    if col < (N - 1):
        spaces = (N - 1) - col
        for i in range(1, spaces + 1):
            if configuration[index + i] != 0:
                return False
            else:
                mirror[index + i] = ROOK

    # mirror to left (if possible)
    if col > 0:
        spaces = col
        for i in range(1, spaces + 1):
            if configuration[index - i] != 0:<commit_msg>fix king movement. It was fixed to 3x3 board<commit_after># -*- coding: utf-8 -*-
import itertools

# pieces
KING = 1
QUEEN = 2
BISHOP = 3
ROOK = 4
KNIGHT = 5

def get_col_by_index(index, N):
    return index % N

def get_line_by_index(index, M):
    if index < M:
        return 1
    elif index == M:
        return 2
    elif index >= (M - 1) * M:
        return M
    else:
        for l in range(2, M):
            if index >= (l - 1) * M and index < l * M:
                return l
    return -1


def mirror_king(index, mirror, configuration, M, N):
    """
    Mirror King's position where it could attack. Returns false if there is a piece in that space.
    A king moves one space to every side.
    """

    col = get_col_by_index(index, N)
    line = get_line_by_index(index, M)

    # mirror to right (if possible)
    if col < (N - 1):
        if configuration[index + 1] != 0:
            return False
        else:
            mirror[index + 1] = KING

    # mirror to left (if possible)
    if col > 0:
        if configuration[index - 1] != 0:
            return False
        else:
            mirror[index - 1] = KING

    # mirror down (if possible)
    if line < M:
        if configuration[index + N] != 0:
            return False
        else:
            mirror[index + N] = KING

    # mirror up (if possible)
    if line > 1:
        if configuration[index - N] != 0:
            return False
        else:
            mirror[index - N] = KING

    # Diagonals

    # upper left
    if col > 0 and line > 1:
        if configuration[index - N - 1] != 0:
            return False
        else:
            mirror[index - N - 1] = KING

    # down left
    if col > 0 and line < M:
        if configuration[index + N - 1] != 0:
            return False
        else:
            mirror[index + N - 1] = KING

    # upper right
    if col < (N - 1) and line > 1:
        if configuration[index - N + 1] != 0:
            return False
        else:
            mirror[index - N + 1] = KING

    # down right
    if col < (N - 1) and line < M:
        if configuration[index + N + 1] != 0:
            return False
        else:
            mirror[index + N + 1] = KING

    return True


def mirror_rook(index, mirror, configuration, M, N):
    """
    Mirror Rook's position where it could attack. Returns false if there is a piece in that space.
    A ROOK moves through intire line and column from its position
    """
    
    col = get_col_by_index(index, N)
    line = get_line_by_index(index, M)

    # mirror to right (if possible)
    if col < (N - 1):
        spaces = (N - 1) - col
        for i in range(1, spaces + 1):
            if configuration[index + i] != 0:
                return False
            else:
                mirror[index + i] = ROOK

    # mirror to left (if possible)
    if col > 0:
        spaces = col
        for i in range(1, spaces + 1):
            if configuration[index - i] != 0:
{'fraction_non_alphanumeric': 0.09943714821763602, 'fraction_numerical': 0.01944397066348286, 'mean_word_length': 1.5451388888888888, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2901825', 'n_tokens_mistral': 1939, 'n_tokens_neox': 1807, 'n_words': 693}