--- 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 %i.fa.fa-linkedin