Created
May 24, 2012 22:42
-
-
Save agoodman/2784660 to your computer and use it in GitHub Desktop.
Word Pruning by Letter Subtraction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
possible_words = ["seek", "find", "ignore", "pursue", "covet"] | |
available_letters = ["a", "c", "e", "f", "g", "i", "n", "o", "p", "r", "t", "u", "v"] | |
words = Array[possible_words].flatten | |
available_letters.each {|e| words = words.map {|w| w.sub(e, '')}} | |
viable_words = words.each_with_index.collect {|w,k| possible_words[k] if w==""}.compact |
word_as_hash = Array.new
viable_words.each do |word|
i = 0
x = word.size
while x > i
word_as_hash << word[i].to_sym
i += 1
end
end
okay so that successfully changes each character to a hash but doesn't keep the words as separate arrays. Ideas?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay so I think the next move is to create an array of hashes of the letters and their values that matches each word and then we can use that later in the board.