code: def coordinates_to_index(self, x, y, x_shift=0, y_shift=0):
          
          target_x = x + x_shift
          target_y = y + y_shift
          self.validate_coordinates(target_x, target_y)
          index = (target_y * self.length) + target_x
          return index
docs: Return a linear index from a set of 2D coordinates.
  
          Optionnal vertical and horizontal shifts might be applied.