Sha256: e80ffb258559b889b1291b18208540dd4ef9c7bc70d223868d2e99fb35603856
Contents?: true
Size: 662 Bytes
Versions: 3
Compression:
Stored size: 662 Bytes
Contents
# encoding: utf-8 ### # @author Dan Oberg <dan@cs1.com> # @licence MIT # @class Scrabble # Useage: `ruby -Ilib ./bin/scrabble {'asdfjkl'}` or `ruby -Ilib ./bin/scrabble {'peodfor'}` ### class Scrabble ### # @param [String] letters are ran against a dictionary for valid scrabble answers. # @return [Array] returns possible valid results. ### def self.run_scrabble(letters) dictionary_path = File.join( File.dirname(__FILE__), 'word_list.txt' ) dictionary = File.readlines(dictionary_path).map(&:chomp) possible = (2..letters.length).map{|n| letters.chars.to_a.permutation(n).to_a.map(&:join)}.flatten dictionary & possible end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
danno_scrabble-0.0.6 | lib/scrabble.rb |
danno_scrabble-0.0.5 | lib/scrabble.rb |
danno_scrabble-0.0.4 | lib/scrabble.rb |