<commit_before>---
title: Word Search Gem
---

.fork
  .block
    = link_to "https://github.com/npezza93/word_search" do
      %i.fa.fa-github
      Fork on GitHub

.container
  %h1.center Word Search
  %h4.center
    Easily create a 2D and 3D word searches of any size given a csv of words

  %br
  %br

  %h3
    Install
  %p
    Add word_search to your Gemfile and bundle install:
    %pre
      %code
        gem "word_search"
    %p
      Alternatively, you can install the gem from rubygems.org and require it in your script:
    %pre
      %code
        gem install word_search

  %br
  %br

  %h3
    Quick Start
  %p
    Using the supplied Generator class you can be up and running in a couple lines:
    %pre
      %code
        :preserve
          require "word_search"

          # You can also add another param, z, to get a 3D word search
          generator = WordSearch::Generator.new("words.csv", 5, 5)
          # Calling #perform will place the words and fill the empty spots
          # with random letters
          generator.perform
          # Call #print to write the word search to a file
          generator.print("word_search")

  %br
  %br

  %h3
    Plane
  %p
    You can load up a word search from a file and have access to a couple
    helpful utilites
  %pre
    %code
      :preserve
        require "word_search"

        plane = WordSearch::Plane.make_from_file("word_search")
        # To find the max of x or y
        plane.x
        => 5
        plane.y
        => 5
        # When a plane is generated, all positions by letter are
        # cataloged into a hash for quick searching.
        plane.catalog
        => {"j"=> [Point @letter="j", @x=0, @y=0>],
            "r"=> [Point @letter="r", @x=1, @y=0>]}
        # To get all possible traversable directions around a point
        plane.directions.to_h
        => { N: [0, 1], NE: [1, 1], E: [1, 0], SE: [1, -1], S: [0, -1],
             SW: [-1, -1], W: [-1, 0], NW: [-1, 1] }
        # To print the plane to the screen
        plane.pto_s
        nvqgy
        uhsit
        zqloh
        muudd
        himyj

  %br
  %br

  %h3
    Solver
  %p
    You can benchmark and check if your solution works by using the Solver class.
    Your script should be an executable ruby script that writes the location
    of each letter to a file in the following format and returns the file path.
    %pre
      :preserve
        h [4, 9]
        e [5, 9]
        l [6, 9]
        l [7, 9]
        o [8, 9]
        ---
        b [6, 8]
        y [7, 7]
        e [8, 6]
  %pre
    %code
      :preserve
        require "word_search"

        plane = WordSearch::Solver.new(
          "path/to/script", "path/to/word/bank", "path/to/word/search"
        )
        solver.perform
        => Benchmark::Tms:0x007fd722cc6b58 @cstime=0.07,
            @cutime=0.44, @label="", @real=0.5259899999946356,
            @stime=0.0, @total=0.51, @utime=0.0
        # If your script fails or is incorrect a message will appear instead
        # of the benchmark.

#np_logo_container
  = link_to "https://github.com/npezza93", class: "social-container" do
    %i.fa.fa-github
  = image_tag "logo.png", id: "np_logo"
  = link_to "https://www.linkedin.com/in/nick-pezza-02166668", class: "social-container" do<commit_msg>Update docs for cmd line arguments<commit_after>---
title: Word Search Gem
---

.fork
  .block
    = link_to "https://github.com/npezza93/word_search" do
      %i.fa.fa-github
      Fork on GitHub

.container
  %h1.center Word Search
  %h4.center
    Easily create a 2D and 3D word searches of any size given a csv of words

  %br
  %br

  %h3
    Install
  %p
    Add word_search to your Gemfile and bundle install:
    %pre
      %code
        gem "word_search"
    %p
      Alternatively, you can install the gem from rubygems.org and require it in your script:
    %pre
      %code
        gem install word_search

  %br
  %br

  %h3
    Quick Start
  %p
    Using the supplied Generator class you can be up and running in a couple lines:
    %pre
      %code
        :preserve
          require "word_search"

          # You can also add another param, z, to get a 3D word search
          generator = WordSearch::Generator.new("words.csv", 5, 5)
          # Calling #perform will place the words and fill the empty spots
          # with random letters
          generator.perform
          # Call #print to write the word search to a file
          generator.print("word_search")

  %br
  %br

  %h3
    Plane
  %p
    You can load up a word search from a file and have access to a couple
    helpful utilites
  %pre
    %code
      :preserve
        require "word_search"

        plane = WordSearch::Plane.make_from_file("word_search")
        # To find the max of x or y
        plane.x
        => 5
        plane.y
        => 5
        # When a plane is generated, all positions by letter are
        # cataloged into a hash for quick searching.
        plane.catalog
        => {"j"=> [Point @letter="j", @x=0, @y=0>],
            "r"=> [Point @letter="r", @x=1, @y=0>]}
        # To get all possible traversable directions around a point
        plane.directions.to_h
        => { N: [0, 1], NE: [1, 1], E: [1, 0], SE: [1, -1], S: [0, -1],
             SW: [-1, -1], W: [-1, 0], NW: [-1, 1] }
        # To print the plane to the screen
        plane.pto_s
        nvqgy
        uhsit
        zqloh
        muudd
        himyj

  %br
  %br

  %h3
    Solver
  %p
    You can benchmark and check if your solution works by using the Solver class.
    Your script should be an executable ruby script that writes the location
    of each letter to a file in the following format and returns the file path.
    It should also be able to accept command line arguments for the plane file
    and the words file, in that order.
    %pre

      :preserve
        h [4, 9]
        e [5, 9]
        l [6, 9]
        l [7, 9]
        o [8, 9]
        ---
        b [6, 8]
        y [7, 7]
        e [8, 6]
  %pre
    %code
      :preserve
        require "word_search"

        plane = WordSearch::Solver.new(
          "path/to/script", "path/to/word/bank", "path/to/word/search"
        )
        solver.perform
        => Benchmark::Tms:0x007fd722cc6b58 @cstime=0.07,
            @cutime=0.44, @label="", @real=0.5259899999946356,
            @stime=0.0, @total=0.51, @utime=0.0
        # If your script fails or is incorrect a message will appear instead
        # of the benchmark.

#np_logo_container
  = link_to "https://github.com/npezza93", class: "social-container" do
    %i.fa.fa-github
  = image_tag "logo.png", id: "np_logo"
  = link_to "https://www.linkedin.com/in/nick-pezza-02166668", class: "social-container" do
{'fraction_non_alphanumeric': 0.10264802142219577, 'fraction_numerical': 0.03005058018446891, 'mean_word_length': 1.8916129032258064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, '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': '1332069', 'n_tokens_mistral': 2337, 'n_tokens_neox': 2192, 'n_words': 785}