At the distance of k in both direction
if ( j == 0 ) : NEW_LINE INDENT row_s = 0 NEW_LINE DEDENT else : NEW_LINE INDENT row_s = row [ i + k ] [ j - 1 ] NEW_LINE DEDENT if ( i == 0 ) : NEW_LINE INDENT col_s = 0 NEW_LINE DEDENT else : NEW_LINE INDENT col_s = col [ i - 1 ] [ j + k ] NEW_LINE DEDENT lower_row = row [ i + k ] [ j + k ] - row_s NEW_LINE right_col = col [ i + k ] [ j + k ] - col_s NEW_LINE