-
-
Save jeffreybaird/2785825 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 = [ "w5","g6","f7","s2","e1","l3","h8","n1","f7","b8","r12","u3","g6","i4","q9","o3","d2","s2","f7"] | |
words = Array[possible_words].flatten | |
available_letters = tiles.map {|e| e[0]} | |
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 | |
letter_value_hash = Hash[tiles.map {|l| [l.slice(0), l.slice(1..3).to_i]}] | |
word_as_values = viable_words.map do |word| | |
word.split("").map {|c| letter_value_hash[c]} | |
end | |
board_as_arrays = board.map{|c| c.split(" ")} | |
space_as_arrays = board_as_arrays.map{|t| t.map {|x| x.to_i} } | |
space_as_arrays.map{|x| x.include?(2) || x.include?(3)} | |
space_as_arrays.each_with_index.map do |word,k| | |
word.each_with_index.map do |number,y| | |
if number.to_i > 1 | |
p "index: [#{y}] [#{k}] value: #{number}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment