Skip to content

Instantly share code, notes, and snippets.

@bparanj
Created July 19, 2021 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bparanj/0114bd840c618c877c36ab710fc8e8cd to your computer and use it in GitHub Desktop.
Save bparanj/0114bd840c618c877c36ab710fc8e8cd to your computer and use it in GitHub Desktop.
def lookup_hash
h = {}
letter = 'a'
count = 1
for i in (1..26)
h[letter] = count
letter = letter.next
count += 1
end
h
end
def hundred_points(word)
lookup = lookup_hash
chars = word.chars
points = 0
chars.each do |c|
c = c.downcase
points += lookup[c]
end
return points == 100
end
words = File.readlines('/usr/share/dict/words')
words.each_with_index do |word, index|
begin
if !word.nil?
p hundred_points(word.strip)
end
rescue
next
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment