<commit_before>module WordPuzzle
  def self.add_word(list, word, y, x)
    if word
      list[word] ||= []
      list[word] << "#{y} #{x}"
    end
  end

  def self.find_words(grid, word_list)
    width = grid[0].size-1
    height = grid.size-1
    size = [width, height].max

    letters = {}
    0.upto(height) do |y|
      0.upto(width) do |x|
        width.downto(x) do |depth|
          add_word letters, grid[y][x..depth], y, x
        end

        height.downto(y) do |depth|
          horizontal_word = ""
          diagonal_word = ""
          depth.downto(y) do |y2|
            if grid[depth]
              horizontal_word = "#{grid[depth][x]}#{horizontal_word}"
              diagonal_word = "#{grid[y2][x+y2-y]}#{diagonal_word}"
            end<commit_msg>Fix problem with horizontal word at end of width<commit_after>module WordPuzzle
  def self.add_word(list, word, y, x)
    if word
      list[word] ||= []
      list[word] << "#{y} #{x}"
    end
  end

  def self.find_words(grid, word_list)
    width = grid[0].size-1
    height = grid.size-1

    letters = {}
    0.upto(height) do |y|
      0.upto(width) do |x|
        width.downto(x) do |depth|
          add_word letters, grid[y][x..depth], y, x
        end

        height.downto(y) do |depth|
          horizontal_word = ""
          diagonal_word = ""
          depth.downto(y) do |y2|
            if grid[depth]
              horizontal_word = "#{grid[y2][x]}#{horizontal_word}"
              diagonal_word = "#{grid[y2][x+y2-y]}#{diagonal_word}"
            end
{'fraction_non_alphanumeric': 0.15009746588693956, 'fraction_numerical': 0.011046133853151396, 'mean_word_length': 2.019607843137255, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '6408974', 'n_tokens_mistral': 556, 'n_tokens_neox': 537, 'n_words': 116}