danno_scrabble 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a977d1c3be79bfd76a20c3c1eb67cd26cffb6298
4
- data.tar.gz: 3cc2674fa6281b70fa241ea92c8d388bc6d98af6
3
+ metadata.gz: aad2e25a1fd3c5295fa464c471d8ac753fe3a7a0
4
+ data.tar.gz: 0e2075abfe6b35de78abf23a7bd3b1ac4b999837
5
5
  SHA512:
6
- metadata.gz: 21a67dec5227d9e187495a9dda9bb8da8987a73c87b3feb8d2a42b2e0a9c5c025cd3b1c7f9e56a8360db4ba12fb906caadc4f74bf342ebe0ac56f689865a97c1
7
- data.tar.gz: 60708fa90a391a410b38717a44fafe2d0bdb71903a786f60159dab108438c0e0bf7f7d2c39a9864e5a47fd7506f87280a2ffdf15c9c863288b048b32110370c6
6
+ metadata.gz: 56cc7404a427024aec7c30669a2acdaa8964e54728fa753255c45dc62f5400b8afc5b96229f9daea670763fc661ed1d08ad0d89c423d8a7e3d44b67bf32ec510
7
+ data.tar.gz: 39ea0f3ba1bf4188928b61a5d5d4f467215b6f653c58f24474ff8a6f319bbdf9e34d9da628ca995631faabfb4564c51f7f4d32fc854cca218f0b8982f7d995b3
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ ____ ___
2
+ | _ \ / _ \
3
+ | | | | | | | |
4
+ | |_| | | |_| |
5
+ |____/[] \ ___ /[]
6
+
7
+ Scrabble has long been used to play on words. For example, you have a set of letters, these letters then make various
8
+ combinations of words. In the rules of scrabble those various combinations of words are compared against a valid scrabble
9
+ dictionary to see if it is a valid answer. This provides a list of all possible valid answers based on the set of letters.
10
+
11
+ # Requirements
12
+
13
+ * Ruby -v 2.2.0+ # Use Rvm where possible `rvm install "version_number"`
14
+ * Install the clock `gem install danno_scrabble` or clone it from this repo.
15
+
16
+ # INFO
17
+
18
+ Sample Input
19
+ "asd"
20
+
21
+ Output for the Sample Input
22
+ ["ad", "ads", "as", "da", "sad"]
23
+
24
+ # Using the Gem!
25
+
26
+ * `ruby -Ilib ./bin/scrabble {'scrabble'}` or `ruby -Ilib ./bin/scrabble {'asdfjkl'}` # if cloned
27
+ * `ruby -Ilib ~/.rvm/gems/ruby-2.2.3/gems/danno_scrabble_0.0.3/bin/scrabble {'scrabble'}` # if installed via `gem install`
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
data/bin/scrabble CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'scrabble'
4
- puts Scrabble.run_scrabble(ARGV[0])
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'scrabble'
4
+ puts Scrabble.run_scrabble(ARGV[0])
data/lib/scrabble.rb CHANGED
@@ -1,18 +1,19 @@
1
- # encoding: utf-8
2
- ###
3
- # @author Dan Oberg <dan@cs1.com>
4
- # @licence MIT
5
- # @class Scrabble
6
- # Useage: `ruby -Ilib ./bin/scrabble {'asdfjkl'}` or `ruby -Ilib ./bin/scrabble {'peodfor'}`
7
- ###
8
- class Scrabble
9
- ###
10
- # @param [String] run a list of letters against a text dictionary file for valid scrabble answers.
11
- # @return [Array] return possible valid results.
12
- ###
13
- def self.run_scrabble(letters)
14
- dictionary = File.readlines('word_list.txt').map(&:chomp)
15
- possible = (2..letters.length).map{|n| letters.chars.to_a.permutation(n).to_a.map(&:join)}.flatten
16
- dictionary & possible
17
- end
18
- end
1
+ # encoding: utf-8
2
+ ###
3
+ # @author Dan Oberg <dan@cs1.com>
4
+ # @licence MIT
5
+ # @class Scrabble
6
+ # Useage: `ruby -Ilib ./bin/scrabble {'asdfjkl'}` or `ruby -Ilib ./bin/scrabble {'peodfor'}`
7
+ ###
8
+ class Scrabble
9
+ ###
10
+ # @param [String] run a list of letters against a text dictionary file for valid scrabble answers.
11
+ # @return [Array] returns possible valid results.
12
+ ###
13
+ def self.run_scrabble(letters)
14
+ dictionary_path = File.join( File.dirname(__FILE__), 'word_list.txt' )
15
+ dictionary = File.readlines(dictionary_path).map(&:chomp)
16
+ possible = (2..letters.length).map{|n| letters.chars.to_a.permutation(n).to_a.map(&:join)}.flatten
17
+ dictionary & possible
18
+ end
19
+ end