Skip to content

Instantly share code, notes, and snippets.

@ajosanchez
Created July 6, 2016 03:00
Show Gist options
  • Save ajosanchez/cdc6c501d9dcd4c68305e96a26372d60 to your computer and use it in GitHub Desktop.
Save ajosanchez/cdc6c501d9dcd4c68305e96a26372d60 to your computer and use it in GitHub Desktop.
def valid_word? word
letters = {
'e' => 12,
'a' => 9,
'i' => 9,
'o' => 8,
'n' => 6,
'r' => 6,
't' => 6,
'l' => 4,
's' => 4,
'u' => 4,
'd' => 4,
'g' => 3,
'b' => 2,
'c' => 2,
'm' => 2,
'p' => 2,
'f' => 2,
'h' => 2,
'v' => 2,
'w' => 2,
'y' => 2,
'k' => 1,
'j' => 1,
'x' => 1,
'q' => 1,
'z' => 1
}
blanks = 2
arr = word.chars
arr.each do |letter|
if letters[letter] > 0
letters['letter'] -= 1
elsif blanks > 0
blanks -= 1
else
response = false
break
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment