Sha256: c0b639894d27615ac060544a998d2a65e98338400a4dc29df8571e35b8ec00bb
Contents?: true
Size: 678 Bytes
Versions: 1
Compression:
Stored size: 678 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] run a list of letters against a text dictionary file 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
danno_scrabble-0.0.3 | lib/scrabble.rb |