<commit_before>def snake_ahead_position(snake, direction)
  [snake.last, direction].transpose.map { |coordinates| coordinates.reduce(:+) }
end

def grow(snake, direction)
  snake + [snake_ahead_position(snake, direction)]
end

def move(snake, direction)
  moved_snake = grow(snake, direction)
  moved_snake.shift
  moved_snake
end

def generate_random_food(dimensions)
  xs = rand(dimensions[:width])
  ys = rand(dimensions[:height])
  [xs, ys]
end

def new_food(food, snake, dimensions)
  if (food.length + snake.length) >= dimensions[:width] * dimensions[:height]
    return []
  end

  random_food = generate_random_food(dimensions)
  while food.include? random_food or snake.include? random_food do
    random_food = generate_random_food(dimensions)
  end

  random_food
end

def not_in_bounds?(position, dimensions)
  xs = position[0]
  ys = position[1]<commit_msg>refactored new_food function<commit_after>def snake_ahead_position(snake, direction)
  [snake.last, direction].transpose.map { |coordinates| coordinates.reduce(:+) }
end

def grow(snake, direction)
  snake + [snake_ahead_position(snake, direction)]
end

def move(snake, direction)
  moved_snake = grow(snake, direction)
  moved_snake.shift
  moved_snake
end

def generate_random_food(dimensions)
  xs = rand(dimensions[:width])
  ys = rand(dimensions[:height])
  [xs, ys]
end

def new_food(food, snake, dimensions)
  random_food = generate_random_food(dimensions)
  while food.include? random_food or snake.include? random_food
    random_food = generate_random_food(dimensions)
  end

  random_food
end

def not_in_bounds?(position, dimensions)
  xs = position[0]
  ys = position[1]
{'fraction_non_alphanumeric': 0.10526315789473684, 'fraction_numerical': 0.0024198427102238356, 'mean_word_length': 5.669354838709677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '618808', 'n_tokens_mistral': 573, 'n_tokens_neox': 565, 'n_words': 123}