https://github.com/npezza93/word_search
Word Search Generator and Solver
https://github.com/npezza93/word_search
Last synced: 3 months ago
JSON representation
Word Search Generator and Solver
- Host: GitHub
- URL: https://github.com/npezza93/word_search
- Owner: npezza93
- License: mit
- Created: 2016-08-21T19:08:23.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-18T20:37:28.000Z (over 2 years ago)
- Last Synced: 2024-04-23T05:45:09.456Z (about 1 year ago)
- Language: Ruby
- Homepage: https://pezza.co/word_search
- Size: 18.6 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Word Search Generator and Solver
[](https://travis-ci.org/npezza93/word_search)
[](https://codeclimate.com/github/npezza93/word_search)
[](https://codeclimate.com/github/npezza93/word_search/coverage)## Install
Add WordSearch to your `Gemfile` and `bundle install`:`gem "word_search"`
Alternatively, you can install the gem from [rubygems.org](https://rubygems.org/):
`gem install word_search`
## Usage
To create a plane with just random letters in each position:
```ruby
❯ plane = WordSearch::Plane.new(5, 5)
❯ plane.add_letters
# To traverse the cartesian plane:
❯ plane[0][3]
=> #
❯ plane.pto_s
nvqgy
uhsit
zqloh
muudd
himyj# To print to a file(without a filename defaults to "word_search")
❯ plane.print(file_name)# When printing a 3D word search there are two spaces between z slices. The top slice is z = 0.
❯ plane = WordSearch::Plane.new(3, 3, 2)
❯ plane.add_letters
❯ plane.pto_s
bxv
lud
agpesj
era
utg
```To create plane filled with words supplied by a word bank:
```ruby
❯ generator = WordSearch::Generator.new("words.csv", 5, 5) # or add a z param to get a 3D word search
❯ generator.perform
❯ generator.word_bank
=> ["word", "hello", "bye"]
❯ generator.pto_s
ghsii
eelwt
ylcon
blarz
yoydt
```To solve or benchmark your solution script:
```ruby
❯ solver = WordSearch::Solver.new(
❯ "path/to/script", "path/to/word/bank", "path/to/word/search"
❯ )
❯ solver.perform
=> #
```
_NOTE_: 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. Your
script should also accept command line arguments the first being the plane file
the second being the word list file.
```
h [4, 9]
e [5, 9]
l [6, 9]
l [7, 9]
o [8, 9]
---
b [6, 8]
y [7, 7]
e [8, 6]
```