def cheating_matrix(seating_chart):
    """
    Calculate and return the probabilities of cheating for each position in a rxc grid
    :param seating_chart: A nested list representing a rxc grid
    :return: A nested list, the same size as seating_chart, with each element representing that
            position's cheating probability
    """

    # Create matrix of probabilities by location
    prob_matrix = [[.025, .3, .025],
                   [.2, 0, .2],
                   [.025, .2, .025]]

    # Create blank nested list for saving calculated probabilities (same size as seating_chart)
    calc_prob = []
    for ch_row in range(len(seating_chart)):
        new_row = []
        for ch_col in range(len(seating_chart[ch_row])):
            new_row.append(seating_chart[ch_row][ch_col])
        calc_prob.append(new_row)

    # calculate probabilities for each spot in seating_chart, store in calc_prob
    for row in range(len(seating_chart)):
        for col in range(len(seating_chart[row])):
            calc_prob[row][col] = 0
            for r_adj in range(-1, 2):
                for c_adj in range(-1, 2):
                    if 0 <= row + r_adj < len(seating_chart):
                        if 0 <= col + c_adj < len(seating_chart[row]):
                            if seating_chart[row][col] == seating_chart[row + r_adj][col + c_adj]:
                                calc_prob[row][col] += prob_matrix[1 + r_adj][1 + c_adj]
    return calc_prob